Altivec compatibility

This section describes the changes in compiler diagnosis on incompatible vector element order, vector types, and vector built-in functions for IBM Open XL C/C++ for AIX 17.1.3 in comparison to IBM® XL C/C++ for AIX® 16.1.0 or earlier releases.

Compatibility of vector types

Compiler diagnosis on incompatible vector types

In IBM XL C/C++ for AIX 16.1.0 or earlier releases, different vector types are incompatible. For example, if a variable of type vector unsigned int is assigned to another variable of type vector signed int, the compiler diagnoses the assignment. In IBM Open XL C/C++ for AIX 17.1.3, assignments between variables of different vector types are not diagnosed by default, which might result in programming errors. To enable the compiler diagnostic function in IBM Open XL C/C++ for AIX 17.1.3, specify the -fno-lax-vector-conversions option.

Operations on the vector bool and vector pixel types

IBM XL C/C++ for AIX 16.1.0 or earlier releases treat operations on the vector bool and vector pixel types differently. See the following two examples:

  • Example 1

    In IBM XL C/C++ for AIX 16.1.0 or earlier releases, when a variable of the vector pixel or vector bool type is to be initialized with a scalar value, all elements of the vector variable are initialized with the scalar value. However, the community Clang compiler initializes only the first element of the vector variable with the scalar value while initializes the rest of elements with zero.

  • Example 2

    In IBM XL C/C++ for AIX 16.1.0 or earlier releases, comparing two vector bool variables results in a scalar value. However, this comparison results in a vector variable in the community Clang compiler.

In IBM Open XL C/C++ for AIX 17.1.3, you can control the compiler behavior through the -faltivec-src-compat option. By default, the option value is -faltivec-src-compat=xl in IBM Open XL C/C++ for AIX 17.1.3 and the compiler behaves the same as IBM XL C/C++ for AIX 16.1.0 or earlier releases. However, you can change the compiler behavior to make it consistent with that of the community Clang compiler by specifying the -faltivec-src-compat=mixed option.

Compatibility of vector built-in functions

Built-in function arguments
The second argument of the following built-in functions needs to be a constant integer that ranges from 0 to 31, inclusive. In IBM XL C/C++ for AIX 16.1.0 or earlier releases, if out-of-range values are passed to the built-in functions, the compiler issues messages. However, in IBM Open XL C/C++ for AIX 17.1.3, when out-of-range values are input, the compiler does not issue messages but the behavior is undefined.
  • vec_ctd
  • vec_ctf
  • vec_cts
  • vec_ctu
  • vec_ctsl
  • vec_ctul

Some built-in functions expect the same argument types for two or more arguments. For example, the prototype of the vec_add(a,b) built-in function requires that argument b has the same type as argument a. However, in IBM XL C/C++ for AIX 16.1.0 or earlier releases, the compiler tolerates the mismatching types of a and b. In IBM Open XL C/C++ for AIX 17.1.3, the mismatching types are not allowed and the compiler issues an error message for it.

Built-in function prototypes
In IBM XL C/C++ for AIX 16.1.0 or earlier releases, the vec_ctf, vec_cts, and vec_ctu built-in functions have the following prototypes:
  • vector float vec_ctf(vector signed long long)
  • vector float vec_ctf(vector unsigned long long)
  • vector signed int vec_cts(vector double)
  • vector unsigned int vec_ctu(vector double)
However, these built-in functions have the following different prototypes in GCC, which are incompatible with those in IBM XL C/C++ for AIX 16.1.0 or earlier releases:
  • vector double vec_ctf(vector signed long long)
  • vector double vec_ctf(vector unsigned long long)
  • vector signed long long vec_cts(vector double)
  • vector unsigned long long vec_ctu(vector double)
In IBM Open XL C/C++ for AIX 17.1.3, you can control which set of built-in prototypes to use through the __XL_COMPAT_ALTIVEC__ macro. By default, IBM Open XL C/C++ for AIX 17.1.3 defines the __XL_COMPAT_ALTIVEC__ macro and provides built-in prototypes that are identical to those in IBM XL C/C++ for AIX 16.1.0 or earlier releases. If compatibility with GCC is required, you can undefine this macro by specifying the -U__XL_COMPAT_ALTIVEC__ option.
Note: The community Clang compiler leaves __XL_COMPAT_ALTIVEC__ undefined by default.

Unsupported built-in functions

IBM Open XL C/C++ for AIX 17.1.3 no longer supports the following built-ins that were supported in IBM XL C/C++ for AIX 16.1.0 or earlier releases:
  • vec_extsbd1
  • vec_extsbw1
  • vec_extshd1
  • vec_extshw1
  • vec_extswd1
  • vec_xxsldi2
Note:
  1. In IBM Open XL C/C++ for AIX 17.1.3, use vec_signexti or vec_signextll as the replacement of the vec_extsbd, vec_extsbw, vec_extshd, vec_extshw, or vec_extswd.
  2. vec_xxsldi was added in IBM XL C/C++ for AIX 16.1.0 invoked by xlclang or xlclang++. In IBM Open XL C/C++ for AIX 17.1.3, use vec_sldw as the replacement of vec_xxsldi.

Related information