HP C Programmer's Guide (92434-90009)
86 Chapter4
Optimizing HP C Programs
Level 1 Optimization Modules
becomes:
if(!a) {
goto L1;
}
statement 1
statement 2
L1:
Dead Code Elimination
The dead code elimination module removes unreachable code that is never executed.
For example, the code:
if(0) {
a=1;
} else {
a=2;
becomes:
a=2;
Faster Register Allocation
The faster register allocation module, used with unoptimized code, analyzes register use
faster than the coloring register allocator (a level 2 module).
This module performs the following:
• Inserts entry and exit code.
• Generates code for operations such as multiplication and division.
• Eliminates unnecessary copy instructions.
• Allocates actual registers to the dummy registers in instructions.
Instruction Scheduler
The instruction scheduler module performs the following:
• Reorders the instructions in a basic block to improve memory pipelining. For example,
where possible, a load instruction is separated from the use of the loaded register.
• Where possible, follows a branch instruction with an instruction that can be executed as
the branch occurs.
• Schedules floating-point instructions.
For example, the code:
LDW -52(0,30),r1
ADDI 3,r1,r31 ;interlock with load of r1
LDI 10,r19
becomes: