@@ -1116,10 +1116,10 @@ template instantiation, so the value for ``T::number`` is known.
1116
1116
def ExtVectorTypeDocs : Documentation {
1117
1117
let Category = DocCatFunction;
1118
1118
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
1120
1120
elements, 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.
1123
1123
This attribute enables efficient SIMD operations and is usable in
1124
1124
general-purpose code.
1125
1125
@@ -1128,17 +1128,16 @@ general-purpose code.
1128
1128
template <typename T, uint32_t N>
1129
1129
constexpr T simd_reduce(T [[clang::ext_vector_type(N)]] v) {
1130
1130
static_assert((N & (N - 1)) == 0, "N must be a power of two");
1131
- if constexpr (N == 1) {
1131
+ if constexpr (N == 1)
1132
1132
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);
1137
1135
}
1138
1136
1139
1137
The 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
+
1142
1141
.. code-block:: c++
1143
1142
1144
1143
using f16_x16 = _Float16 __attribute__((ext_vector_type(16)));
0 commit comments