D.2. Optimization Levels

The default is optimization set to -O2. This results in the fastest compile times, but XGC Ada makes absolutely no attempt to optimize, and the generated programs are considerably larger and slower. You can use the -On switch, where n is an integer from 0 to 3, on the gcc command to control the optimization level:

-O0

no optimization

-O1

medium level optimization

-O2

full optimization (the default)

-O3

full optimization, and also attempt automatic inlining of small subprograms within a unit (see Section D.3).

The penalty in compilation time, and the improvement in execution time, both depend on the particular application and the hardware environment. You should experiment to find the best level for your application.

Note: Unlike the case with some other compiler systems, gcc has been tested extensively at all optimization levels. There are some bugs which appear only with optimization turned on, but there have also been bugs which show up only in unoptimized code. Selecting a lower level of optimization does not improve the reliability of the code generator, which in practice is highly reliable at all optimization levels.