Optimization Levels
Optimization Levels
Optimization Scope
Optimization Scope
FILE1.C
FILE1.C
{
{
{
{
SESE
SESE
}
}
{
{
. . .
. . .
}
}
}
}
{
{
. . .
. . .
}
}
FILE2.C
FILE2.C
-
-
o0,
o0,
-
-
o1
o1
-
-
o2
o2
-
-
o3
o3
-
-
pm
pm
-
-
o3
o3
SESE: Single Entry, Single Exit
SESE: Single Entry, Single Exit
LOCAL
LOCAL
single block
single block
FUNCTION
FUNCTION
across
across
blocks
blocks
FILE
FILE
across
across
functions
functions
PROGRAM
PROGRAM
across files
across files
{
{
. . .
. . .
}
}
Optimizations fall into 4 categories. This is also a methodology that should be used to invoke the
optimizations. It is recommended that optimization be invoked in steps, and that code be verified
before advancing to the next step. Intermediate steps offer the gradual transition from fully sym-
bolic to fully optimized compilation. Compiler switched may be invoked in a variety of ways.
Here are 4 steps that could be considered:
1
st
: use –g
By starting out with –g, you do no optimization at all and keep symbols for debug.
2
nd
: use –g –o3
The option –o3 might be too big a jump, but it adds the optimizer and keeps symbols.
3
rd
: use –g –o3 –mn
This is a full optimization, but keeps some symbols
4
th
: use –o3
Full optimization, symbols are not kept.
C28x – C Programming D - 9