My linker (or compiler?) generated strange NOP 9 byte sequences in my code between the functions...
66 0f 1f 84 00 00 00 nop word [rax+rax]
00 00 ---
Why does it put these in there? Alignment (address of the procedure after the bytes happens to be 16-aligned, so I'm guessing that can be the case)?
Is it related to the ICache maybe?
Thanks
Random NOP bytes in my binary
-
- Member
- Posts: 5513
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Random NOP bytes in my binary
It's for alignment. Most CPUs fetch instructions in 16-byte blocks, so aligning functions to 16-byte boundaries means the CPU can decode more instructions before it needs to fetch the next block.
Agner Fog's optimization guides explain it in more detail.
Agner Fog's optimization guides explain it in more detail.
Re: Random NOP bytes in my binary
Thanks! I thought it might be related to it, but I wasn't sureOctocontrabass wrote:It's for alignment. Most CPUs fetch instructions in 16-byte blocks, so aligning functions to 16-byte boundaries means the CPU can decode more instructions before it needs to fetch the next block.
Agner Fog's optimization guides explain it in more detail.