| |||
| Home > Compiler Command-line Options > --reassociate_saturation, --no_reassociate_saturation | |||
These options enable and disable more aggressive optimization in loops that use saturating arithmetic.
Saturating additions do not have associative property. Therefore
by default, the compiler does not re-associate saturating additions. --reassociate_saturation instructs
the compiler to re-associate saturating additions to perform optimization. --no_reassociate_saturation prohibits
re-association of saturating addition, and thus limits the level
of optimization on saturating arithmetic. --reassociate_saturation enables
optimizations such as vectorizing code when automatic vectorization
is enabled using --vectorize. It also enables
other optimizations when --vectorize is not specified,
for example when compiling with -O3 -Otime.
Saturating addition is not associative, so enabling --reassociate_saturation could affect the result with a reduction in accuracy.
The following code contains the function L_mac,
which performs saturating additions. Therefore the compiler does
not vectorize this code unless --reassociate_saturation and --vectorize are specified.
#include <dspfns.h>
int f(short *a, short *b)
{
int i;
int r = 0;
for (i = 0; i < 100; i++)
r=L_mac(r,a[i],b[i]);
return r;
}
Automatic vectorization in Using the Compiler.