Zuxy Meng wrote:
"Mike Stump" <[EMAIL PROTECTED]>
??????:[EMAIL PROTECTED]
On Apr 8, 2007, at 2:37 AM, Uros Bizjak wrote:
My docs say that "INC/DEC does not change the carry flag".
Personally, I'm having a hard time envisioning how the semantics of the
instruction are relevant at all. This is all about instructing tuning,
so, semantics cannot matter, otherwise, it would be wrong to make this a
tune choice.
Intel's optimization reference manual says that:
3.5.1.1 Use of the INC and DEC Instructions
The INC and DEC instructions modify only a subset of the bits in the flag
register. This creates a dependence on all previous writes of the flag
register. This is especially problematic when these instructions are on the
critical path because they are used to change an address for a load on which
many other instructions depend.
Assembly/Compiler Coding Rule 32. (M impact, H generality)
INC and DEC instructions should be replaced with ADD or SUB instructions,
because ADD and SUB overwrite all flags, whereas INC and DEC do not,
therefore creating false dependencies on earlier instructions that set the
flags.
That is probably one part of the true. Another part is that usage of
inc/dec results in smaller code, better code locality and faster code.
What is more important? This is hard to say. But I've checked SPEC2000
for gcc (revision 122995) again and see that usage of inc/dec gives not
worse code (actually it is a bit better: 1939 without inc/dec vs 1944
with inc/dec for SPECInt2000 and 1724 vs 1727 for SPECFp2000) besides
the code with usage of inc/dec is 0.39% for SPECInt and 0.11% for SPECFp
smaller.
Vlad