Handling Floating-point Array Operations in a Loop Body
- Statements within the loop body may contain float or double operations (typically on arrays). The following arithmetic operations are supported: addition, subtraction, multiplication, division, negation, square root, MAX, MIN, and mathematical functions such as SIN and COS.
- Writing to a single-precision scalar/array and a double scalar/array within the same loop decreases the chance of auto-vectorization due to the differences in the vector length (that is, the number of elements in the vector register) between float and double types. If auto-vectorization fails, try to avoid using mixed data types.
Reducing the Impact of
- Scale the values into the normalized range
- Use a higher precision data type with a larger range
- Flushdenormalsto zero
Avoiding Mixed Data Type Arithmetic Expressions
int I, J; I = J / 2.0 ;
int I, J; I = J / 2;
Using Efficient Data Types
- long long
- long double