Re: Efficiency
- From: "Rod Pemberton" <do_not_have@xxxxxxxxxxxxx>
- Date: Fri, 26 Oct 2007 20:11:14 -0400
"KJH" <k_jh77@xxxxxxxxx> wrote in message
news:1193417360.765130.21700@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Why is it so that nowadays:
mov eax,[esi]
mov [edi],eax
is more efficient than
lodsd
stosd
I think you basically answered this:
... also it seems that modern Pentiums and above really like
their instructions more RISC-like (aka boring instr set).
lods/stos have a number of problems from a compiler perspective. A compiler
has to figure out what registers to use to implement the compiled code. The
compiler wants instructions which are easy to use, fast, and orthogonal.
The compiler wants to maximize the use of the registers and not ignore
registers that it could be using - because not doing so wastes cpu time.
The lods/stos instructions are slow on older cpu's. The mov instructions
are equivalent to or faster, on cpu's which pair instructions, than
lods/stos. The mov instructions can also be reordered to eliminate push/pop
instructions or separated to prevent register stalls. The the mov
instructions are also more orthogonal. The compiler has a choice of many
register combinations with mov instead of just eax, es:edi, or ds:esi. So,
from the compiler perspective, use of lods/stos become special cases. The
compiler might implement these for some compile option such as compile for
size, instead of speed. If an extremely fast xchg instruction had been
implemented, then use of lods/stos might've been common in x86 compilers.
Rod Pemberton
.
- References:
- Efficiency
- From: KJH
- Efficiency
- Prev by Date: Re: Skybuck's Wolfram (Turing-Like) Machine implementation
- Next by Date: Slow nasm
- Previous by thread: Re: Efficiency
- Next by thread: Re: Efficiency
- Index(es):
Relevant Pages
|