@@ -19,6 +19,8 @@ typedef double vector4double __attribute__((__vector_size__(32)));
19
19
typedef float vector4float __attribute__ ((__vector_size__(16 )));
20
20
typedef long long vector4long __attribute__ ((__vector_size__(32 )));
21
21
typedef int vector4int __attribute__ ((__vector_size__(16 )));
22
+ typedef unsigned long long vector4ulong __attribute__ ((__vector_size__(32 )));
23
+ typedef unsigned int vector4uint __attribute__ ((__vector_size__(16 )));
22
24
typedef short vector4short __attribute__ ((__vector_size__(8 )));
23
25
typedef char vector4char __attribute__ ((__vector_size__(4 )));
24
26
typedef BitInt8 vector4BitInt8 __attribute__ ((__vector_size__(4 )));
@@ -723,3 +725,23 @@ not within the bounds of the input vectors; index of -1 found at position 0 is n
723
725
permitted in a constexpr context}}
724
726
vector4charConst1,
725
727
vector4charConst2, -1 , -1 , -1 , -1 );
728
+
729
+ static_assert (__builtin_reduce_add((vector4char){}) == 0 );
730
+ static_assert (__builtin_reduce_add((vector4char){1 , 2 , 3 , 4 }) == 10 );
731
+ static_assert (__builtin_reduce_add((vector4short){10 , 20 , 30 , 40 }) == 100 );
732
+ static_assert (__builtin_reduce_add((vector4int){100 , 200 , 300 , 400 }) == 1000 );
733
+ static_assert (__builtin_reduce_add((vector4long){1000 , 2000 , 3000 , 4000 }) == 10000 );
734
+ constexpr int reduceAddInt1 = __builtin_reduce_add((vector4int){~(1 << 31 ), 0 , 0 , 1 });
735
+ // expected-error@-1 {{must be initialized by a constant expression}} \
736
+ // expected-note@-1 {{outside the range of representable values of type 'int'}}
737
+ constexpr long long reduceAddLong1 = __builtin_reduce_add((vector4long){~(1LL << 63 ), 0 , 0 , 1 });
738
+ // expected-error@-1 {{must be initialized by a constant expression}} \
739
+ // expected-note@-1 {{outside the range of representable values of type 'long long'}}
740
+ constexpr int reduceAddInt2 = __builtin_reduce_add((vector4int){(1 << 31 ), 0 , 0 , -1 });
741
+ // expected-error@-1 {{must be initialized by a constant expression}} \
742
+ // expected-note@-1 {{outside the range of representable values of type 'int'}}
743
+ constexpr long long reduceAddLong2 = __builtin_reduce_add((vector4long){(1LL << 63 ), 0 , 0 , -1 });
744
+ // expected-error@-1 {{must be initialized by a constant expression}} \
745
+ // expected-note@-1 {{outside the range of representable values of type 'long long'}}
746
+ static_assert (__builtin_reduce_add((vector4uint){~0U , 0 , 0 , 1 }) == 0 );
747
+ static_assert (__builtin_reduce_add((vector4ulong){~0ULL , 0 , 0 , 1 }) == 0 );
0 commit comments