|
|
HP C/HP-UX Programmer's Guide: HP 9000 Computers > Chapter 4 Optimizing HP C Programs Level 4 Optimizations |
|
Level 4 performs optimizations across all files in a program. At level 4, all optimizations of the prior levels are performed. Two additional optimizations are performed:
Interprocedural global optimizations across all files within a program searches across function boundaries to produce better and faster code sequences. Normally, global optimizations are performed within individual functions or source code files. Interprocedural optimizations look at function interactions within a program and transform particular code sequences into faster code. Since information about every function within a program is required, this level of optimization must be performed at link time. Inlining at Level 4 is performed across all procedures within the program. Inlining at level 3 is done within one file. Inlining substitutes function calls with copies of the function"s object code. Only functions that meet the optimizer"s criteria are inlined. This may result in slightly larger executable files. However, this increase in size is offset by the elimination of time-consuming procedure calls and procedure returns. Global and static variable optimizations look for ways to reduce the number of instructions required for accessing global and static variables. The compiler normally generates two machine instructions when referencing global variables. Depending on the locality of the global variables, single machine instructions may sometimes be used to access these variables. The linker rearranges the storage location of global and static data to increase the number of variables that can be referenced by single instructions. Since this optimization rearranges the location and data alignment of global variables, avoid the following programming practices:
|
|