vec_lvsl

Purpose

Returns a vector useful for aligning non-aligned data.

Syntax

d=vec_lvsl(a, b)

Result and argument types

The following table describes the types of the returned value and the function arguments.

d a b
vector4double long double*
_Complex double*
float*
_Complex float*

Result value

The result value is a quad vector. The elements of the quad vector are generated in the following ways:

You can use the result as an argument of the vec_perm function.

Formula

The following formula is applicable if b is a pointer to a double-precision floating-point value or complex value:

EA = a + b
AA = EA AND 0b11000
Offset = AA58:60
d[0] = (double) {sign = 0, mantissa =  Offset             , exponent = 0x400}
d[1] = (double) {sign = 0, mantissa = (Offset+1) AND 0b111, exponent = 0x400}
d[2] = (double) {sign = 0, mantissa = (Offset+2) AND 0b111, exponent = 0x400}
d[3] = (double) {sign = 0, mantissa = (Offset+3) AND 0b111, exponent = 0x400}

The following formula is applicable if b is a pointer to a single-precision floating-point value or complex value:

EA = a + b
AA = (EA × 2) AND 0b11000
Offset = AA58:60
d[0] = (double) {sign = 0, mantissa =  Offset             , exponent = 0x400}
d[1] = (double) {sign = 0, mantissa = (Offset+1) AND 0b111, exponent = 0x400}
d[2] = (double) {sign = 0, mantissa = (Offset+2) AND 0b111, exponent = 0x400}
d[3] = (double) {sign = 0, mantissa = (Offset+3) AND 0b111, exponent = 0x400}
Note:
  • AND is the bitwise AND operator.

Example: Loading 8-byte aligned vectors

// my_array is an array of the double type
vector4double v, v1, v2, vp;
v1 = vec_ld(0,my_array)    // Load the left part of the vector
v2 = vec_ld(32,my_array)   // Load the right part of the vector
vp = vec_lvsl(0,my_array)  // Generate control value
v  = vec_perm(v1,v2,vp)    // Generate the aligned vector

Example: Loading 4-byte aligned vectors

// my_array is an array of the float type
vector4double v, v1, v2, vp;
v1 = vec_ld(0,my_array)    // Load the left part of the vector
v2 = vec_ld(16,my_array)   // Load the right part of the vector
vp = vec_lvsl(0,my_array)  // Generate control value
v  = vec_perm(v1,v2,vp)    // Generate the aligned vector