Looking purely at speed ( clock ticks ) which code executes faster ?[code][color=Blue]mov eax,gs:[edi+4]


add edi,4
mov eax,gs:[edi][/color][/code]


  • I'd say the second one is slower, because the addition is a read-modify-write operation, so edi will be tied up for several uops. This is bad, since the second instruction depends on edi. Also, the first one takes less space, so it fits into cache better.

    However, the second code may improve performance if you insert some other instruction between add and mov. If that instruction doesn't use edi, then it could be fed into another pipeline and executed in parallel.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion