Atmel CAVR-4 Manual De Usuario
CAVR-4
124
Taking advantage of the compilation system
AVR® IAR C/C++ Compiler
Reference Guide
Code motion
Evaluation of loop-invariant expressions and common subexpressions are moved to
avoid redundant re-evaluation. This optimization, which is performed at optimization
level Medium, normally reduces code size and execution time. The resulting code might
however be difficult to debug.
avoid redundant re-evaluation. This optimization, which is performed at optimization
level Medium, normally reduces code size and execution time. The resulting code might
however be difficult to debug.
Note: This option has no effect at optimization levels None, and Low.
Type-based alias analysis
When two or more pointers reference the same memory location, these pointers are said
to be aliases for each other. The existence of aliases makes optimization more difficult
because it is not necessarily known at compile time whether a particular value is being
changed.
to be aliases for each other. The existence of aliases makes optimization more difficult
because it is not necessarily known at compile time whether a particular value is being
changed.
Type-based alias analysis optimization assumes that all accesses to an object will take
place using its declared type or as a
place using its declared type or as a
char
type. This assumption lets the compiler detect
whether pointers may reference the same memory location or not.
Type-based alias analysis is performed at optimization level High. For ISO/ANSI
standard-conforming C or C++ application code, this optimization can reduce code size
and execution time. However, non-standard-conforming C or C++ code might result in
the compiler producing code that leads to unexpected behavior. Therefore, it is possible
to turn this optimization off.
standard-conforming C or C++ application code, this optimization can reduce code size
and execution time. However, non-standard-conforming C or C++ code might result in
the compiler producing code that leads to unexpected behavior. Therefore, it is possible
to turn this optimization off.
Note: This option has no effect at optimization levels None, Low, and Medium.
To read more about the command line option, see --no_tbaa, page 191.
Example
short f(short * p1, long * p2)
{
*p2 = 0;
*p1 = 1;
return *p2;
}
With type-based alias analysis, it is assumed that a write access to the
short
pointed to
by
p1
cannot affect the
long
value that
p2
points to. Thus, it is known at compile time
that this function returns 0. However, in non-standard-conforming C or C++ code these
pointers could overlap each other by being part of the same union. By using explicit
casts, you can also force pointers of different pointer types to point to the same memory
location.
pointers could overlap each other by being part of the same union. By using explicit
casts, you can also force pointers of different pointer types to point to the same memory
location.