flat assembler
Message board for the users of flat assembler.

Index > Main > register renaming cost

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 679
Location: Marseille/France
sylware 24 Sep 2026, 13:21
On modern micro-architectures, is there a significant "cost" for register renaming?

Because with APX, machine instructions with a destination register different than the source registers should invade the x86_64 space (and we may get 32 registers).
Post 24 Sep 2026, 13:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21155
Location: In your JS exploiting you and your system
revolution 24 Sep 2026, 13:44
What cost is being measured? Compared to what? Because renaming can't be turned off to measure any difference between off or on.

With regard to "32" registers, that hasn't been valid for a long time. There are more than 200 registers in many CPU cores produced today. Renaming just picks a few out of the pool for each instruction.
Post 24 Sep 2026, 13:44
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 679
Location: Marseille/France
sylware 24 Sep 2026, 14:02
Is this picking has a cost, namely will it cost extra cycles?
Post 24 Sep 2026, 14:02
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21155
Location: In your JS exploiting you and your system
revolution 24 Sep 2026, 14:28
There are no extra cycles for register allocation, because there is no way to turn it off to compare.

If it takes 100 cycle to allocate a register then that is just how the CPU works. There isn't an alternative path that doesn't do register renaming.

Overall, register renaming is a win (it has many advantages), or otherwise the makers would kill it and boast everywhere how they made the CPU "faster".
Post 24 Sep 2026, 14:28
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 679
Location: Marseille/France
sylware 24 Sep 2026, 15:10
I could code in a way to reduce register renaming pressure. That's why I did ask if there is a cost as extra cycles.

So you say there is none of those extra cycles on modern micro-architectures.

Good!
Post 24 Sep 2026, 15:10
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21155
Location: In your JS exploiting you and your system
revolution 24 Sep 2026, 15:21
There aren't any "extra" cycles.

Any cycles taken to pick a register are just how it works. The pipeline might have zero, one, two or a million cycles for the renaming stage. But those aren't "extra" cycles, they are normal cycles. There isn't a way to avoid it. All code is stuck with it. There isn't a way to "code in a way to reduce register renaming pressure" because all code passes through the renaming stage(s).*

* Maybe "nop" is special and can bypass some stages or something, IDK, but nop doesn't do anything that can affect the state of the register set.
Post 24 Sep 2026, 15:21
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 679
Location: Marseille/France
sylware 26 Sep 2026, 10:14
Ok. So register renaming is "always" (i.e. with enough testing) there and has a static cost.
Post 26 Sep 2026, 10:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21155
Location: In your JS exploiting you and your system
revolution 26 Sep 2026, 11:29
sylware wrote:
Ok. So register renaming is "always" (i.e. with enough testing) there and has a static cost.
Have a look at the pipeline diagrams of the CPU. There is a fixed number of stages for renaming. No bypass is available to skip a stage. If such a bypass did exist for a subset of instructions then those instructions jumping ahead would collide with others already ahead of them.

So far, as of today, there is no variable number of cycles where some instructions use X cycles, and others use Y. Perhaps tomorrow a new architecture comes out that changes that?
Post 26 Sep 2026, 11:29
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2767
Furs 26 Sep 2026, 22:28
revolution wrote:
So far, as of today, there is no variable number of cycles where some instructions use X cycles, and others use Y. Perhaps tomorrow a new architecture comes out that changes that?
Just to be clear he's talking about the same "type" of instruction but different place/execution (e.g. both adds or both subs etc). Cause obviously a div is slower.
Post 26 Sep 2026, 22:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 21155
Location: In your JS exploiting you and your system
revolution 27 Sep 2026, 03:21
Furs wrote:
revolution wrote:
So far, as of today, there is no variable number of cycles where some instructions use X cycles, and others use Y. Perhaps tomorrow a new architecture comes out that changes that?
Just to be clear he's talking about the same "type" of instruction but different place/execution (e.g. both adds or both subs etc). Cause obviously a div is slower.
I was talking about the renaming part of the pipeline. It applies to all instructions, regardless of type.
Post 27 Sep 2026, 03:21
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.