Java Reference
In-Depth Information
and then searching for a single instruction that has the same e
ect as the
combined pair. To be applicable, an instruction must perform all the register
transfers of the combined instructions. It may also perform other register
transfers as long as these are on dead registers (and therefore would have no
e
ff
ect on subsequent computations). Thus, an instruction may set a condition
code, even if this is not wanted, as long as the updated condition code is not
referenced by later instructions.
Instruction pairs that start with a conditional branch get special treatment.
In particular, the second instruction is prefixedwith a conditional representing
the negation of the original condition (the only way the second instruction is
executed is if the conditional branch fails). An unconditional branch is paired
with its target instruction. This pairing often allows jump chains (a jump to
another jump) to be collapsed. Note, however, that instruction pairs with the
second instruction labeled are not optimized. This situation is needed to make
jumps to such labels work correctly. However, if all references to a label are
removed by the PO, then the label itself is also removed, possibly allowing
new optimizations to be discovered.
The analysis and simplification of the instructions just described are not
actually done during compilation because this would be far too slow. Rather,
representative samples of actual programs are analyzed in advance, and the
most common peephole optimizations are stored in a table. During compi-
lation, this table is consulted to determine if the instructions currently in the
peephole may be optimized.
ff
Search WWH ::




Custom Search