Clearing Registers; Compares - Intel ARCHITECTURE IA-32 Reference Manual

Architecture optimization
Table of Contents

Advertisement

Clearing Registers

Pentium 4 processor provides special support to
operations when executed within the same register. This recognizes that
clearing a register does not depend on the old value of the register. The
and
xorps
cannot be used to break dependence chains.
In Intel Core Solo and Intel Core Duo processors; the
or
instructions can be used to clear execution dependencies on the
pxor
zero evaluation of the destination register.
Assembly/Compiler Coding Rule 51. (M impact, ML generality) Use
, or
sub
pxor
resulting from re-use of registers. In contexts where the condition codes must
be preserved, move
than using

Compares

Use
test
essentially
register.
Test
register.
Test
smaller.
Use
test
constant for equality or inequality if the register is
as:
if (avar & 8) { }
The
test
power of 2. For example, the C code:
if ( (avar % 16) == 0 ) { }
can be implemented using:
test eax, 0x0F
jnz
instructions do not have this special support. They
xorpd
to set a register to
into the register instead. This requires more code space
0
and
, but avoids setting the condition codes.
xor
sub
when comparing a value in a register with zero.
s the operands together without writing to a destination
and
is preferred over
is better than
cmp ..., 0
when comparing the result of a logical
instruction can also be used to detect rollover of modulo a
AfterIf
General Optimization Guidelines
xor
, or to break a false dependence chain
0
because
produces an extra result
and
and
because the instruction size is
and
2
,
, or
sub
pxor
,
,
xor
sub
xorps
xor
Test
with an immediate
for cases such
eax
2-87
,
,

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ARCHITECTURE IA-32 and is the answer not in the manual?

Table of Contents

Save PDF