Compiling C/C++ Code
3-12
3.2.3
Performing Program-Level Optimization (–pm Option)
You can specify program-level optimization by using the –pm option with the
–o3 option. With program-level optimization, all your source files are compiled
into one intermediate file giving the compiler complete program view during
compilation. This creates significant advantage for determining pointer loca-
tins passed into a function. Once the compiler determines two pointers do not
access the same memory location, substantial improvements can be made in
software pipelined loops. Because the compiler has access to the entire pro-
gram, it performs several additional optimizations rarely applied during file-lev-
el optimization:
-
If a particular argument in a function always has the same value, the com-
piler replaces the argument with the value and passes the value instead
of the argument.
-
If a return value of a function is never used, the compiler deletes the return
code in the function.
-
If a function is not called, directly or indirectly, the compiler removes the
function.
Also, using the –pm option can lead to better schedules for your loops. If the
number of iterations of a loop is determined by a value passed into the function,
and the compiler can determine what that value is from the caller, then the
compiler will have more information about the minimum trip count of the loop
leading to a better resulting schedule.