By: EduardoS (no.delete@this.spam.com), May 7, 2013 9:18 am
Room: Moderated Discussions
Exophase (exophase.delete@this.gmail.com) on May 7, 2013 9:05 am wrote:
> I wonder if there's any detail available about how many times a load is referenced in typical compiled code..
Not most cases but still a lot, the point is that, in x86, the destructive nature of the instructions prevent many of the cases where the load-op optimization would be possible, for example, if we need to add [esi] and eax to edx preserving eax there is two options:
mov edx, eax
add edx, [esi]
or
mov edx, [esi]
add edx, eax
The latter were faster in some (almost all?) x86 processors so compilers usually favor it.
When optimizing assembly code for K-8 some times I replaced loads used more than once for load ops to reduce the number of instructions since K-8 was able to execute 2 laod per cycle but only 3 instructions, but for Intel processors this wasn't a speed up.
> I wonder if there's any detail available about how many times a load is referenced in typical compiled code..
Not most cases but still a lot, the point is that, in x86, the destructive nature of the instructions prevent many of the cases where the load-op optimization would be possible, for example, if we need to add [esi] and eax to edx preserving eax there is two options:
mov edx, eax
add edx, [esi]
or
mov edx, [esi]
add edx, eax
The latter were faster in some (almost all?) x86 processors so compilers usually favor it.
When optimizing assembly code for K-8 some times I replaced loads used more than once for load ops to reduce the number of instructions since K-8 was able to execute 2 laod per cycle but only 3 instructions, but for Intel processors this wasn't a speed up.