How are scalars dealt with in vectorization?
If a scalar variable is only used (not set) in a loop, then for AltiVec the scalar will be “splatted” into a vector register (replicated in each postion in the vector register) and the result used in the vector calculation. Scalars that are set and then used in a loop are “promoted” to vectors. These scalars are generally holding temporary values in a loop that we now need to temporary vector values. In the example, below, x is a “used” scalar and y is a “promoted” scalar: C Fortran float a[99], b[99], x, y; int i, n; for ( i=0; i < n; i++ ) { y = x + b[i]; a[i] = y + 1/y; } real a(99), b(99), x, y int i, n do i= 1, n y = x + b(i) a[i] = y + 1/y enddo Scalar that are used before they are set in a loop are called "carry-around" scalars. They are a problem for vectorization since the value computed in one pass of the loop is used in the next pass of the loop (the value is "carried" from one pass to the next).