Reduce Procedure Calls

Procedure calls in code limit optimization because some registers cannot be k ept live (retain values) across calls. Y ou can remove calls to user procedures from the main body of code and, instead, branch to a common area. Figure 5-5 sho ws an example of reducing procedure calls.

Figure 5-5. Reducing Procedure Calls

Expand Small Procedures In-line

Expanding a small procedure in-line increases the scope for the optimizer, reduces procedure call overhead, and allows additional constan t folding of constan t value parameters. You should expand procedures shorter than ￿v e lines. Figure 5-6 sho ws an example of expanding a procedure in F ORTRAN 77/iX. In HP P ascal/iX, the you can use the compiler option $OPTION INLINE$ to expand the code for a routine in-line at the poin t of call.

Figure 5-6. Expanding Small Procedures In-line

Optimizing a Program 5-7