Optimization Pragmas

Following are the optimization pragmas supported by the HP aC++ compiler:

OPT_LEVEL Pragma

#pragma OPT_LEVEL 0 #pragma OPT_LEVEL 1 #pragma OPT_LEVEL 2 #pragma OPT_LEVEL 3 #pragma OPT_LEVEL 4 #pragma OPT_LEVEL INITIAL

When used with a numeric argument, the OPT_LEVEL pragma sets the optimization level to 0, 1, 2, 3, or 4.

The INITIAL argument causes the optimization level in effect at the start of the compilation, whether by default or specified on the command line, to be restored.

Example:

aCC -O prog.C

#pragma OPT_LEVEL 1

void A(){ // Optimize this function at level 1.

...

}

#pragma OPT_LEVEL 2

void B(){ // Restore optimization to level 2.

...

}

NOTE: This pragma cannot raise the optimization level above the level specified in the command line.

This pragma cannot be used within a function.

OPTIMIZE Pragma

#pragma OPTIMIZE ONOFF

NOTE: This pragma is deprecated as of HP C/C++ A.06.15. You should use: #pragma OPT_LEVEL instead.

This pragma is used to toggle between optimization on and optimization off for different sections of source code whenever they are encountered in a top-to-bottom read of a source file.

Example:

The following example toggles between optimization on and optimization off:

aCC +O2

prog.C

#pragma

OPTIMIZE OFF

void A(){

// Turn off optimization

...

 

// for this function

}

 

 

#pragma

OPTIMIZE ON

void B(){

// Restore optimization

...

 

// to level 2.

}

 

 

You must specify one of the optimization level options on the aCC command, otherwise this pragma is ignored. This pragma cannot be used within a function.

FLOAT_TRAPS_ON Pragma

#pragma FLOAT_TRAPS_ON [function {,function}]

Optimization Pragmas 103

Page 103
Image 103
HP C/aC++ for PA-RISC Software manual Optimization Pragmas, Optlevel Pragma, Optimize Pragma, Floattrapson Pragma