@@ -1116,10 +1116,10 @@ template instantiation, so the value for ``T::number`` is known.
11161116def ExtVectorTypeDocs : Documentation {
11171117 let Category = DocCatFunction;
11181118 let Content = [{
1119- The ext_vector_type(N) attribute specifies that a type is a vector with N
1119+ The `` ext_vector_type(N)`` attribute specifies that a type is a vector with N
11201120elements, directly mapping to an LLVM vector type. Originally from OpenCL, it
1121- allows element access the array subscript operator ``[]``, ``sN`` where ``N`` is
1122- a hexadecimal value, or ``x``, ``y``, ``z``, `` w`` for graphics-style indexing.
1121+ allows element access the array subscript operator ``[]``, ``sN`` where N is
1122+ a hexadecimal value, or ``x, y, z, w`` for graphics-style indexing.
11231123This attribute enables efficient SIMD operations and is usable in
11241124general-purpose code.
11251125
@@ -1128,17 +1128,16 @@ general-purpose code.
11281128 template <typename T, uint32_t N>
11291129 constexpr T simd_reduce(T [[clang::ext_vector_type(N)]] v) {
11301130 static_assert((N & (N - 1)) == 0, "N must be a power of two");
1131- if constexpr (N == 1) {
1131+ if constexpr (N == 1)
11321132 return v[0];
1133- } else {
1134- T [[clang::ext_vector_type(N / 2)]] reduced = v.hi + v.lo;
1135- return simd_reduce(reduced);
1136- }
1133+ else
1134+ return simd_reduce<T, N / 2>(v.hi + v.lo);
11371135 }
11381136
11391137The vector type also supports swizzling up to sixteen elements. This can be done
1140- using the object accessors. The OpenCL documentation lists the full list of
1141- accepted values.
1138+ using the object accessors. The OpenCL documentation lists all of the accepted
1139+ values.
1140+
11421141.. code-block:: c++
11431142
11441143 using f16_x16 = _Float16 __attribute__((ext_vector_type(16)));
0 commit comments