HP C Programmer's Guide (92434-90009)
Chapter 4 87
Optimizing HP C Programs
Level 1 Optimization Modules
LDW -52(0,sp),r1
LDI 10,r19
ADDI 3,r1,r31 ;use of r1 is now separated from load
Peephole Optimizations
The peephole optimization process involves looking at small windows of machine code for
optimization opportunities. Wherever possible, the peephole optimizer replaces assembly
language instruction sequences with faster (usually shorter) sequences, and removes
redundant register loads and stores.
For example, the code:
LDI 32,r3
AND r1,r3,r2
COMIB,= 0,r2,L1
becomes:
BB,>= r1, 26, L1
Table 4-5. Descriptions of Assembly Language Instructions
Instruction Description
LDW offset(sr, base), target Loads a word from memory into register target.
ADDI const, reg, target Adds the constant const to the contents of register reg and puts the
result in register target.
LDI const, target Loads the constant const into register target.
LDO const(reg),target Adds the constant const to the contents of register reg and puts the
result in register target.
AND reg1, reg2, target Performs a bitwise AND of the contents of registers reg1 and reg2
and puts the result in register target.
COMIB cond const, reg, lab Compares the constant const to the contents of register reg and
branches to label lab if the condition cond is true.
BB cond reg,num,lab Tests the bit number num in the contents of register reg and
branches to label lab if the condition cond is true.
COPY reg, target Copies the contents of register reg to register target.
STW reg, offset(sr, base) Store the word in register reg to memory.