HP C Programmer's Guide (92434-90009)

80 Chapter4
Optimizing HP C Programs
Controlling Specific Optimizer Features
Dynamic cast is allowed with +Optrs_strongly_typed or +Optrs_ansi. A pointer
dereference is called dynamic cast if a cast is applied on the pointer to a different type.
In the example below, type-inferred aliasing is applied on P generally, not just to the
particular dereference. Type-aliasing will be applied to any other dereferences of P.
struct s {
short int a;
short int b;
int c;
}*P
* (int *)P = 0;
For more information about type aliasing see the section "Aliasing Options" at the end of
this chapter.
+O[no]ptrs_to_globals[=
name1, name2, ...nameN
]
Optimization level(s): 2, 3, 4
Default: +Optrs_to_globals
By default global variables are conservatively assumed to be modified anywhere in the
program. Use this option to specify which global variables are not modified through
pointers, so that the optimizer can make your program run more efficiently by
incorporating copy propagation and common sub-expression elimination.
This option can be used to specify all global variables as not modified via pointers, or to
specify a comma-separated list of global variables as not modified via pointers.
Note that the
on
state for this option disables some optimizations, such as aggressive
optimizations on the program's global symbols.
For example, use the command line option +Onoptrs_to_globals=a,b,c to specify global
variables a, b, and c as not being accessed through pointers. No pointer can access these
global variables. The optimizer will perform copy propagation and constant folding
because storing to *p will not modify a or b.
int a, b, c;
float *p;
foo()
{
a = 10;
b = 20;
*p = 1.0;
c=a+b;
}
If all global variables are unique, use the following option without listing the global
variables:
+Onoptrs_to_globals
In the example below, the address of b is taken. This means b can be accessed indirectly
through the pointer. You can still use +Onoptrs_to_globals as: +Onoptrs_to_globals
+Optrs_to_globals=b.
int b,c;