Anyone know what the purpose of the mov edi, edi instruction there is?
Edited to add: I understand that it's a NOP, but why would the compiler emit one here?
Edited to add: I understand that it's a NOP, but why would the compiler emit one here?
edi register is the lower 4 bytes of rdi. Instructions which write these smaller pieces zero out the unused higher bytes of the destination registers. This helps with performance because eliminates data dependencies on the old values in these higher bytes.
mov eax, OFFSET FLAT:.LC0
cmp rdi, 258
ja .L1
mov rax, QWORD PTR CSWTCH.1[0+rdi*8]
Note that in some cases the compiler can do this automatically via lifetime analysis but not in this freestanding example.[0]: https://devblogs.microsoft.com/oldnewthing/20110921-00/?p=95...