HP 3000 Manuals

Controlling Specific Optimizer Features on HP-UX [ HP C Programmer's Guide ] MPE/iX 5.0 Documentation


HP C Programmer's Guide

Controlling Specific Optimizer Features on HP-UX 

Most of the time, specifying optimization level 1, 2, 3, or 4 should
provide you with the control over the optimizer that you need.
Additional parameters are provided when you require a finer level of
control.

At each level, you can turn on and off specific optimizations using the
+O[no]optimization option.  The optimization parameter is the name of a
specific optimization technique.  The optional prefix [no] disables the
specified optimization.

Table 4-4  describes the optimizations that can be turned on or off: 

          Table 4-4.  Advanced Optimization Options 

-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       Optimization       |                     What It Does                      | Level of |
|          Option          |                                                       |   Opt    |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|     +O[no]initcheck      | The initialization checking feature of the optimizer  | 2, 3, 4  |
|                          | has three possible states:  on, off, or unspecified.  |          |
|                          | When on (+Oinitcheck), the optimizer initializes to   |          |
|                          | zero any local, scalar, non-static variables that are |          |
|                          | uninitialized with respect to at least one path       |          |
|                          | leading to a use of the variable.                     |          |
|                          |                                                       |          |
|                          | When off (+Onoinitcheck), the optimizer issues        |          |
|                          | warning messages when it discovers definitely         |          |
|                          | uninitialized variables, but does not initialize      |          |
|                          | them.                                                 |          |
|                          |                                                       |          |
|                          | When unspecified, the optimizer initializes to zero   |          |
|                          | any local, scalar, non-static variables that are      |          |
|                          | definitely uninitialized with respect to all paths    |          |
|                          | leading to a use of the variable.                     |          |
|                          |                                                       |          |
|                          | Use +Oinitcheck to look for variables in a program    |          |
|                          | that may not be initialized.                          |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|    +O[no]parmsoverlap    | Optimize with the assumption that the actual          | 2, 3, 4  |
|                          | arguments of function calls do [or do not] overlap in |          |
|                          | memory.  The +Onoparmsoverlap option replaces the     |          |
|                          | obsolete +Om1 option.                                 |          |
|                          |                                                       |          |
|                          | The default is +Oparmsoverlap.                        |          |
|                          |                                                       |          |
|                          | Use +Onoparmsoverlap if C programs have been          |          |
|                          | literally translated from FORTRAN programs.           |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------

          Table 4-4.  Advanced Optimization Options (cont.) 

-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       Optimization       |                     What It Does                      | Level of |
|          Option          |                                                       |   Opt    |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|      +O[no]volatile      | The +Ovolatile option implies that memory references  | 1,2,3,4  |
|                          | to global variables cannot be removed during          |          |
|                          | optimization.                                         |          |
|                          |                                                       |          |
|                          | The +Onovolatile option implies that all globals are  |          |
|                          | not of volatile class.  This means that references to |          |
|                          | global variables can be removed during optimization.  |          |
|                          |                                                       |          |
|                          |                                                       |          |
|                          | The +Ovolatile option replaces the obsolete +OV       |          |
|                          | option.                                               |          |
|                          |                                                       |          |
|                          | The default is +Onovolatile.                          |          |
|                          |                                                       |          |
|                          | Use this toggle to control the "volatile" semantics   |          |
|                          | for all global variables.                             |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|   +O[no]inline[=name1,   | When +Oinline is specified without a name list, any   | 3, 4     |
|     name2, ...nameN]     | function can be inlined.  When specified with a name  |          |
|                          | list, the named functions are important candidates    |          |
|                          | for inlining.  The +Onoinline option disables         |          |
|                          | inlining for all functions or a specific list.        |          |
|                          |                                                       |          |
|                          | The default is +Oinline.                              |          |
|                          |                                                       |          |
|                          | Use this toggle when you need to precisely control    |          |
|                          | which functions are inlined.                          |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------

          Table 4-4.  Advanced Optimization Options (cont.) 

-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       Optimization       |                     What It Does                      | Level of |
|          Option          |                                                       |   Opt    |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|      +O[no]libcalls      | Expand [or do not expand] the following library calls | 0,1,2,3,4|
|                          | inline:  strcpy(), sqrt(), fabs(), and alloca().      |          |
|                          | Also use [or do not use] millicode instead of certain |          |
|                          | math library calls.  The +Olibcalls option replaces   |          |
|                          | the obsolete -J option.                               |          |
|                          |                                                       |          |
|                          | The default is +Onolibcalls.                          |          |
|                          |                                                       |          |
|                          | Use +Olibcalls to improve the performance of selected |          |
|                          | library routines only when you are not performing     |          |
|                          | error checking for these routines.                    |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|     +O[no]moveflops      | Allows [or disallows] moving conditional floating     | 2, 3, 4  |
|                          | point instructions out of loops.  The +Onomoveflops   |          |
|                          | option replaces the obsolete +OE option.  The         |          |
|                          | behavior of floating-point exception handling may be  |          |
|                          | altered by this option.                               |          |
|                          |                                                       |          |
|                          | The default is +Omoveflops.                           |          |
|                          |                                                       |          |
|                          | Use +Onomoveflops if floating-point traps are enabled |          |
|                          | and you do not want the behavior of floating-point    |          |
|                          | exceptions to be altered by the relocation of         |          |
|                          | floating-point instructions.                          |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------

          Table 4-4.  Advanced Optimization Options (cont.) 

-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       Optimization       |                     What It Does                      | Level of |
|          Option          |                                                       |   Opt    |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|      +O[no]pipeline      | Enables [or disables] software pipelining.  The       | 2, 3, 4  |
|                          | +Onopipeline option replaces the obsolete +Os option. |          |
|                          |                                                       |          |
|                          |                                                       |          |
|                          | The default is +Opipeline.                            |          |
|                          |                                                       |          |
|                          | Use +Onopipeline to conserve code space.              |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|     +O[no]entrysched     | Optimizes instruction scheduling on a procedure's     | 1,2,3,4  |
|                          | entry and exit sequences.                             |          |
|                          |                                                       |          |
|                          | The default is +Onoentrysched.                        |          |
|                          |                                                       |          |
|                          | This option can change the behavior of programs that  |          |
|                          | perform exception-handling or that handle             |          |
|                          | asynchronous interrupts.                              |          |
|                          |                                                       |          |
|                          | The behavior of setjmp and longjmp is not effected.   |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|    +O[no]regionsched     | Apply aggressive scheduling techniques to move        | 2, 3, 4  |
|                          | instructions across branches.  This toggle is         |          |
|                          | incompatible with the linker -z option.  If used with |          |
|                          | -z, it may cause a SIGSEGV error at run-time.         |          |
|                          |                                                       |          |
|                          | The default is +Onoregionsched.                       |          |
|                          |                                                       |          |
|                          | Use +Oregionsched to improve application run-time     |          |
|                          | speed.                                                |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|   +O[no]signedpointers   | Perform [or do not perform] optimizations related to  | 0,1,2,3,4|
|                          | treating pointers as signed quantities.  Applications |          |
|                          | that allocate shared memory and that compare a        |          |
|                          | pointer to shared memory with a pointer to private    |          |
|                          | memory may run incorrectly if this optimization is    |          |
|                          | enabled.                                              |          |
|                          |                                                       |          |
|                          | The default is +Onosignedpointers.                    |          |
|                          |                                                       |          |
|                          | Use +Osignedpointers to improve application run-time  |          |
|                          | speed.                                                |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------

          Table 4-4.  Advanced Optimization Options (cont.) 

-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       Optimization       |                     What It Does                      | Level of |
|          Option          |                                                       |   Opt    |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|    +O[no]sideeffects=    | Assume that subprograms specified in the name list    | 2, 3, 4  |
| [name1, name2,...,nameN] | might modify global variables.  Therefore, when       |          |
|                          | +Osideeffects is enabled the optimizer limits global  |          |
|                          | variable optimization.                                |          |
|                          |                                                       |          |
|                          | The default is to assume that all subprograms have    |          |
|                          | side effects unless the optimizer can determine that  |          |
|                          | there are none.                                       |          |
|                          |                                                       |          |
|                          | Use +Onosideeffects if you know that the named        |          |
|                          | functions do not modify global variables and you wish |          |
|                          | to achieve the best possible performance.             |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|     +O[no]regreassoc     | If disabled, this toggle turns off register           | 2, 3, 4  |
|                          | reassociation.                                        |          |
|                          |                                                       |          |
|                          | The default is +Oregreassoc.                          |          |
|                          |                                                       |          |
|                          | Use +Onoregreassoc to disable register reassociation  |          |
|                          | if this optimization hinders the optimized            |          |
|                          | application performance.                              |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|     +O[no]fastaccess     | Optimize for fast access to global data items.        | 2, 3, 4  |
|                          |                                                       |          |
|                          | The default is +Onofastaccess at optimization levels  |          |
|                          | 2 and 3, and +Ofastaccess at optimization level 4.    |          |
|                          |                                                       |          |
|                          | Use +Ofastaccess to improve execution speed at the    |          |
|                          | expense of longer compile times.                      |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------
|                          |                                                       |          |
|       +O[no]fltacc       | Disable or enable optimizations that cause imprecise  | 2, 3, 4  |
|                          | floating-point results.                               |          |
|                          |                                                       |          |
|                          | The default is is +Ofltacc.  +Ofltacc disables        |          |
|                          | optimizations that cause imprecise floating-point     |          |
|                          | results.                                              |          |
|                          |                                                       |          |
|                          | Use +Onofltacc to improve execution speed at the      |          |
|                          | expense of floating-point precision.  Include it in   |          |
|                          | the list of options that +Oaggressive sets.           |          |
|                          |                                                       |          |
-----------------------------------------------------------------------------------------------



MPE/iX 5.0 Documentation