3.7 Data references within a vectorizable loop

To vectorize, the compiler has to identify variables with a vector access pattern. It also has to ensure that there are no data dependencies between different iterations of the loop.

Data references in your code can be classified as one of three types:

Scalar

A single value that does not change throughout all of the loop iterations.

Index

An integer quantity that increments by a constant amount each pass through the loop.

Vector

A range of memory locations with a constant stride between consecutive elements.

The following example shows the classification of variables in a loop:

i,j

index variables

a,b

vectors

n,x

scalar

float *a, *b;
int i, j, n, x;
...
for (i = 0; i < n; i++)
{
    *(a+j) = x + b[i];
    j += 2;
};
Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.