7.131 --reassociate_saturation, --no_reassociate_saturation

Enables and disables more aggressive optimization in loops that use saturating arithmetic.

Usage

Saturating addition is not associative. That is, (x+y)+z might not be equal to x+(y+z). For example, with a saturating maximum of 50, (40+20)-10 = 40 while 40+(20-10) = 50.
Some compiler optimizations rely on associativity, using re-association to rearrange expressions into a more efficient sequence.
The --no_reassociate_saturation option prohibits re-association of saturating addition, and therefore limits the level of optimization on saturating arithmetic.
The --reassociate_saturation option instructs the compiler to re-associate saturating additions, enabling the following optimizations:
  • Vectorization of saturating arithmetic when compiling with --vectorize.
  • Other optimizations may be performed when compiling without --vectorize, for example with -O3 -Otime.

Restriction

Saturating addition is not associative, so enabling --reassociate_saturation could affect the result with a reduction in accuracy.

Default

The default is --no_reassociate_saturation.

Examples

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;
}
Non-ConfidentialPDF file icon PDF versionARM DUI0375E
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.