Vectors (GNU Compiler Collection (GCC) Internals)

#### 11.6.4 Vectors ¶

`VEC_DUPLICATE_EXPR`

  This node has a single operand and represents a vector in which every element is equal to that operand.

`VEC_SERIES_EXPR`

  This node represents a vector formed from a scalar base and step, given as the first and second operands respectively. Element i of the result is equal to ‘`base + i*step`’.

  This node is restricted to integral types, in order to avoid specifying the rounding behavior for floating-point types.

`VEC_LSHIFT_EXPR`
`VEC_RSHIFT_EXPR`

  These nodes represent whole vector left and right shifts, respectively. The first operand is the vector to shift; it will always be of vector type. The second operand is an expression for the number of bits by which to shift. Note that the result is undefined if the second operand is larger than or equal to the first operand’s type size.

`VEC_WIDEN_MULT_HI_EXPR`
`VEC_WIDEN_MULT_LO_EXPR`

  These nodes represent widening vector multiplication of the high and low parts of the two input vectors, respectively. Their operands are vectors that contain the same number of elements (`N`) of the same integral type. The result is a vector that contains half as many elements, of an integral type whose size is twice as wide. In the case of `VEC_WIDEN_MULT_HI_EXPR` the high `N/2` elements of the two vector are multiplied to produce the vector of `N/2` products. In the case of `VEC_WIDEN_MULT_LO_EXPR` the low `N/2` elements of the two vector are multiplied to produce the vector of `N/2` products.

`IFN_VEC_WIDEN_PLUS`

  This internal function represents widening vector addition of two input vectors. Its operands are vectors that contain the same number of elements (`N`) of the same integral type. The result is a vector that contains the same amount (`N`) of elements, of an integral type whose size is twice as wide, as the input vectors. If the current target does not implement the corresponding optabs the vectorizer may choose to split it into either a pair of `IFN_VEC_WIDEN_PLUS_HI` and `IFN_VEC_WIDEN_PLUS_LO` or `IFN_VEC_WIDEN_PLUS_EVEN` and `IFN_VEC_WIDEN_PLUS_ODD`, depending on what optabs the target implements.

`IFN_VEC_WIDEN_PLUS_HI`
`IFN_VEC_WIDEN_PLUS_LO`

  These internal functions represent widening vector addition of the high and low parts of the two input vectors, respectively. Their operands are vectors that contain the same number of elements (`N`) of the same integral type. The result is a vector that contains half as many elements, of an integral type whose size is twice as wide. In the case of `IFN_VEC_WIDEN_PLUS_HI` the high `N/2` elements of the two vectors are added to produce the vector of `N/2` additions. In the case of `IFN_VEC_WIDEN_PLUS_LO` the low `N/2` elements of the two vectors are added to produce the vector of `N/2` additions.

`IFN_VEC_WIDEN_PLUS_EVEN`
`IFN_VEC_WIDEN_PLUS_ODD`

  These internal functions represent widening vector addition of the even and odd elements of the two input vectors, respectively. Their operands are vectors that contain the same number of elements (`N`) of the same integral type. The result is a vector that contains half as many elements, of an integral type whose size is twice as wide. In the case of `IFN_VEC_WIDEN_PLUS_EVEN` the even `N/2` elements of the two vectors are added to produce the vector of `N/2` additions. In the case of `IFN_VEC_WIDEN_PLUS_ODD` the odd `N/2` elements of the two vectors are added to produce the vector of `N/2` additions.

`IFN_VEC_WIDEN_MINUS`

  This internal function represents widening vector subtraction of two input vectors. Its operands are vectors that contain the same number of elements (`N`) of the same integral type. The result is a vector that contains the same amount (`N`) of elements, of an integral type whose size is twice as wide, as the input vectors. If the current target does not implement the corresponding optabs the vectorizer may choose to split it into either a pair of `IFN_VEC_WIDEN_MINUS_HI` and `IFN_VEC_WIDEN_MINUS_LO` or `IFN_VEC_WIDEN_MINUS_EVEN` and `IFN_VEC_WIDEN_MINUS_ODD`, depending on what optabs the target implements.

`IFN_VEC_WIDEN_MINUS_HI`
`IFN_VEC_WIDEN_MINUS_LO`

  These internal functions represent widening vector subtraction of the high and low parts of the two input vectors, respectively. Their operands are vectors that contain the same number of elements (`N`) of the same integral type. The high/low elements of the second vector are subtracted from the high/low elements of the first. The result is a vector that contains half as many elements, of an integral type whose size is twice as wide. In the case of `IFN_VEC_WIDEN_MINUS_HI` the high `N/2` elements of the second vector are subtracted from the high `N/2` of the first to produce the vector of `N/2` subtractions. In the case of `IFN_VEC_WIDEN_MINUS_LO` the low `N/2` elements of the second vector are subtracted from the low `N/2` of the first to produce the vector of `N/2` subtractions.

`IFN_VEC_WIDEN_MINUS_EVEN`
`IFN_VEC_WIDEN_MINUS_ODD`

  These internal functions represent widening vector subtraction of the even and odd parts of the two input vectors, respectively. Their operands are vectors that contain the same number of elements (`N`) of the same integral type. The even/odd elements of the second vector are subtracted from the even/odd elements of the first. The result is a vector that contains half as many elements, of an integral type whose size is twice as wide. In the case of `IFN_VEC_WIDEN_MINUS_EVEN` the even `N/2` elements of the second vector are subtracted from the even `N/2` of the first to produce the vector of `N/2` subtractions. In the case of `IFN_VEC_WIDEN_MINUS_ODD` the odd `N/2` elements of the second vector are subtracted from the odd `N/2` of the first to produce the vector of `N/2` subtractions.

`IFN_VEC_TRUNC_ADD_HIGH`

  This internal function performs an addition of two input vectors, then extracts the most significant half of each result element and narrows it to elements of half the original width.

  Concretely, it computes: `(bits(a)/2)((a + b) >> bits(a)/2)`

  where `bits(a)` is the width in bits of each input element.

  Its operands are vectors containing the same number of elements (`N`) of the same integral type. The result is a vector of length `N`, with elements of an integral type whose size is half that of the input element type.

  This operation currently only used for early break result compression when the result of a vector boolean can be represented as 0 or -1.

`VEC_UNPACK_HI_EXPR`
`VEC_UNPACK_LO_EXPR`

  These nodes represent unpacking of the high and low parts of the input vector, respectively. The single operand is a vector that contains `N` elements of the same integral or floating point type. The result is a vector that contains half as many elements, of an integral or floating point type whose size is twice as wide. In the case of `VEC_UNPACK_HI_EXPR` the high `N/2` elements of the vector are extracted and widened (promoted). In the case of `VEC_UNPACK_LO_EXPR` the low `N/2` elements of the vector are extracted and widened (promoted).

`VEC_UNPACK_FLOAT_HI_EXPR`
`VEC_UNPACK_FLOAT_LO_EXPR`

  These nodes represent unpacking of the high and low parts of the input vector, where the values are converted from fixed point to floating point. The single operand is a vector that contains `N` elements of the same integral type. The result is a vector that contains half as many elements of a floating point type whose size is twice as wide. In the case of `VEC_UNPACK_FLOAT_HI_EXPR` the high `N/2` elements of the vector are extracted, converted and widened. In the case of `VEC_UNPACK_FLOAT_LO_EXPR` the low `N/2` elements of the vector are extracted, converted and widened.

`VEC_UNPACK_FIX_TRUNC_HI_EXPR`
`VEC_UNPACK_FIX_TRUNC_LO_EXPR`

  These nodes represent unpacking of the high and low parts of the input vector, where the values are truncated from floating point to fixed point. The single operand is a vector that contains `N` elements of the same floating point type. The result is a vector that contains half as many elements of an integral type whose size is twice as wide. In the case of `VEC_UNPACK_FIX_TRUNC_HI_EXPR` the high `N/2` elements of the vector are extracted and converted with truncation. In the case of `VEC_UNPACK_FIX_TRUNC_LO_EXPR` the low `N/2` elements of the vector are extracted and converted with truncation.

`VEC_PACK_TRUNC_EXPR`

  This node represents packing of truncated elements of the two input vectors into the output vector. Input operands are vectors that contain the same number of elements of the same integral or floating point type. The result is a vector that contains twice as many elements of an integral or floating point type whose size is half as wide. The elements of the two vectors are demoted and merged (concatenated) to form the output vector.

`VEC_PACK_SAT_EXPR`

  This node represents packing of elements of the two input vectors into the output vector using saturation. Input operands are vectors that contain the same number of elements of the same integral type. The result is a vector that contains twice as many elements of an integral type whose size is half as wide. The elements of the two vectors are demoted and merged (concatenated) to form the output vector.

`VEC_PACK_FIX_TRUNC_EXPR`

  This node represents packing of elements of the two input vectors into the output vector, where the values are converted from floating point to fixed point. Input operands are vectors that contain the same number of elements of a floating point type. The result is a vector that contains twice as many elements of an integral type whose size is half as wide. The elements of the two vectors are merged (concatenated) to form the output vector.

`VEC_PACK_FLOAT_EXPR`

  This node represents packing of elements of the two input vectors into the output vector, where the values are converted from fixed point to floating point. Input operands are vectors that contain the same number of elements of an integral type. The result is a vector that contains twice as many elements of floating point type whose size is half as wide. The elements of the two vectors are merged (concatenated) to form the output vector.

`VEC_COND_EXPR`

  These nodes represent `?:` expressions. The three operands must be vectors of the same size and number of elements. The second and third operands must have the same type as the entire expression. The first operand is of signed integral vector type. If an element of the first operand evaluates to a zero value, the corresponding element of the result is taken from the third operand. If it evaluates to a minus one value, it is taken from the second operand. It should never evaluate to any other value currently, but optimizations should not rely on that property. In contrast with a `COND_EXPR`, all operands are always evaluated.

`SAD_EXPR`

  This node represents the Sum of Absolute Differences operation. The three operands must be vectors of integral types. The first and second operand must have the same type. The size of the vector element of the third operand must be at lease twice of the size of the vector element of the first and second one. The SAD is calculated between the first and second operands, added to the third operand, and returned.