883 lines · cpp
1// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -std=c++14 -fsyntax-only -verify2// RUN: %clang_cc1 %s -triple x86_64-linux-gnu -fexperimental-new-constant-interpreter -std=c++14 -fsyntax-only -verify3 4using FourCharsVecSize __attribute__((vector_size(4))) = char;5using FourIntsVecSize __attribute__((vector_size(16))) = int;6using FourLongLongsVecSize __attribute__((vector_size(32))) = long long;7using FourFloatsVecSize __attribute__((vector_size(16))) = float;8using FourDoublesVecSize __attribute__((vector_size(32))) = double;9using FourI128VecSize __attribute__((vector_size(64))) = __int128;10 11using FourCharsExtVec __attribute__((ext_vector_type(4))) = char;12using FourIntsExtVec __attribute__((ext_vector_type(4))) = int;13using FourLongLongsExtVec __attribute__((ext_vector_type(4))) = long long;14using FourFloatsExtVec __attribute__((ext_vector_type(4))) = float;15using FourDoublesExtVec __attribute__((ext_vector_type(4))) = double;16using FourI128ExtVec __attribute__((ext_vector_type(4))) = __int128;17 18// Next a series of tests to make sure these operations are usable in19// constexpr functions. Template instantiations don't emit Winvalid-constexpr,20// so we have to do these as macros.21#define MathShiftOps(Type) \22 constexpr auto MathShiftOps##Type(Type a, Type b) { \23 a = a + b; \24 a = a - b; \25 a = a * b; \26 a = a / b; \27 b = a + 1; \28 b = a - 1; \29 b = a * 1; \30 b = a / 1; \31 a += a; \32 a -= a; \33 a *= a; \34 a /= a; \35 b += a; \36 b -= a; \37 b *= a; \38 b /= a; \39 b = (a += a); \40 b = (a -= a); \41 b = (a *= a); \42 b = (a /= a); \43 b = (b += a); \44 b = (b -= a); \45 b = (b *= a); \46 b = (b /= a); \47 a < b; \48 a > b; \49 a <= b; \50 a >= b; \51 a == b; \52 a != b; \53 a &&b; \54 a || b; \55 auto c = (a, b); \56 return c; \57 }58 59// Ops specific to Integers.60#define MathShiftOpsInts(Type) \61 constexpr auto MathShiftopsInts##Type(Type a, Type b) { \62 a = a << b; \63 a = a >> b; \64 a = a << 3; \65 a = a >> 3; \66 a = 3 << b; \67 a = 3 >> b; \68 a <<= b; \69 a >>= b; \70 a <<= 3; \71 a >>= 3; \72 b = (a <<= b); \73 b = (a >>= b); \74 b = (a <<= 3); \75 b = (a >>= 3); \76 a = a % b; \77 a &b; \78 a | b; \79 a ^ b; \80 return a; \81 }82 83MathShiftOps(FourCharsVecSize);84MathShiftOps(FourIntsVecSize);85MathShiftOps(FourLongLongsVecSize);86MathShiftOps(FourI128VecSize);87MathShiftOps(FourFloatsVecSize);88MathShiftOps(FourDoublesVecSize);89MathShiftOps(FourCharsExtVec);90MathShiftOps(FourIntsExtVec);91MathShiftOps(FourLongLongsExtVec);92MathShiftOps(FourI128ExtVec);93MathShiftOps(FourFloatsExtVec);94MathShiftOps(FourDoublesExtVec);95 96MathShiftOpsInts(FourCharsVecSize);97MathShiftOpsInts(FourIntsVecSize);98MathShiftOpsInts(FourLongLongsVecSize);99MathShiftOpsInts(FourI128VecSize);100MathShiftOpsInts(FourCharsExtVec);101MathShiftOpsInts(FourIntsExtVec);102MathShiftOpsInts(FourLongLongsExtVec);103MathShiftOpsInts(FourI128ExtVec);104 105template <typename T, typename U>106constexpr auto CmpMul(T t, U u) {107 t *= u;108 return t;109}110template <typename T, typename U>111constexpr auto CmpDiv(T t, U u) {112 t /= u;113 return t;114}115template <typename T, typename U>116constexpr auto CmpRem(T t, U u) {117 t %= u;118 return t;119}120 121template <typename T, typename U>122constexpr auto CmpAdd(T t, U u) {123 t += u;124 return t;125}126 127template <typename T, typename U>128constexpr auto CmpSub(T t, U u) {129 t -= u;130 return t;131}132 133template <typename T, typename U>134constexpr auto CmpLSH(T t, U u) {135 t <<= u;136 return t;137}138 139template <typename T, typename U>140constexpr auto CmpRSH(T t, U u) {141 t >>= u;142 return t;143}144 145template <typename T, typename U>146constexpr auto CmpBinAnd(T t, U u) {147 t &= u;148 return t;149}150 151template <typename T, typename U>152constexpr auto CmpBinXOr(T t, U u) {153 t ^= u;154 return t;155}156 157template <typename T, typename U>158constexpr auto CmpBinOr(T t, U u) {159 t |= u;160 return t;161}162 163constexpr auto CmpF(float t, float u) {164 return __builtin_fabs(t - u) < 0.0001;165}166 167// Only int vs float makes a difference here, so we only need to test 1 of each.168// Test Char to make sure the mixed-nature of shifts around char is evident.169void CharUsage() {170 constexpr auto a = FourCharsVecSize{6, 3, 2, 1} +171 FourCharsVecSize{12, 15, 5, 7};172 static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8, "");173 174 constexpr auto b = FourCharsVecSize{19, 15, 13, 12} -175 FourCharsVecSize{13, 14, 5, 3};176 static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9, "");177 178 constexpr auto c = FourCharsVecSize{8, 4, 2, 1} *179 FourCharsVecSize{3, 4, 5, 6};180 static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6, "");181 182 constexpr auto d = FourCharsVecSize{12, 12, 10, 10} /183 FourCharsVecSize{6, 4, 5, 2};184 static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5, "");185 186 constexpr auto e = FourCharsVecSize{12, 12, 10, 10} %187 FourCharsVecSize{6, 4, 4, 3};188 static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1, "");189 190 constexpr auto f = FourCharsVecSize{6, 3, 2, 1} + 3;191 static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4, "");192 193 constexpr auto g = FourCharsVecSize{19, 15, 12, 10} - 3;194 static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7, "");195 196 constexpr auto h = FourCharsVecSize{8, 4, 2, 1} * 3;197 static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3, "");198 199 constexpr auto j = FourCharsVecSize{12, 15, 18, 21} / 3;200 static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7, "");201 202 constexpr auto k = FourCharsVecSize{12, 17, 19, 22} % 3;203 static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1, "");204 205 constexpr auto l = 3 + FourCharsVecSize{6, 3, 2, 1};206 static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4, "");207 208 constexpr auto m = 20 - FourCharsVecSize{19, 15, 12, 10};209 static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10, "");210 211 constexpr auto n = 3 * FourCharsVecSize{8, 4, 2, 1};212 static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3, "");213 214 constexpr auto o = 100 / FourCharsVecSize{12, 15, 18, 21};215 static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4, "");216 217 constexpr auto p = 100 % FourCharsVecSize{12, 15, 18, 21};218 static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16, "");219 220 constexpr auto q = FourCharsVecSize{6, 3, 2, 1} << FourCharsVecSize{1, 1, 2, 2};221 static_assert(q[0] == 12 && q[1] == 6 && q[2] == 8 && q[3] == 4, "");222 223 constexpr auto r = FourCharsVecSize{19, 15, 12, 10} >>224 FourCharsVecSize{1, 1, 2, 2};225 static_assert(r[0] == 9 && r[1] == 7 && r[2] == 3 && r[3] == 2, "");226 227 constexpr auto s = FourCharsVecSize{6, 3, 5, 10} << 1;228 static_assert(s[0] == 12 && s[1] == 6 && s[2] == 10 && s[3] == 20, "");229 230 constexpr auto t = FourCharsVecSize{19, 15, 10, 20} >> 1;231 static_assert(t[0] == 9 && t[1] == 7 && t[2] == 5 && t[3] == 10, "");232 233 constexpr auto u = 12 << FourCharsVecSize{1, 2, 3, 3};234 static_assert(u[0] == 24 && u[1] == 48 && u[2] == 96 && u[3] == 96, "");235 236 constexpr auto v = 12 >> FourCharsVecSize{1, 2, 2, 1};237 static_assert(v[0] == 6 && v[1] == 3 && v[2] == 3 && v[3] == 6, "");238 239 constexpr auto w = FourCharsVecSize{1, 2, 3, 4} <240 FourCharsVecSize{4, 3, 2, 1};241 static_assert(w[0] == -1 && w[1] == -1 && w[2] == 0 && w[3] == 0, "");242 243 constexpr auto x = FourCharsVecSize{1, 2, 3, 4} >244 FourCharsVecSize{4, 3, 2, 1};245 static_assert(x[0] == 0 && x[1] == 0 && x[2] == -1 && x[3] == -1, "");246 247 constexpr auto y = FourCharsVecSize{1, 2, 3, 4} <=248 FourCharsVecSize{4, 3, 3, 1};249 static_assert(y[0] == -1 && y[1] == -1 && y[2] == -1 && y[3] == 0, "");250 251 constexpr auto z = FourCharsVecSize{1, 2, 3, 4} >=252 FourCharsVecSize{4, 3, 3, 1};253 static_assert(z[0] == 0 && z[1] == 0 && z[2] == -1 && z[3] == -1, "");254 255 constexpr auto A = FourCharsVecSize{1, 2, 3, 4} ==256 FourCharsVecSize{4, 3, 3, 1};257 static_assert(A[0] == 0 && A[1] == 0 && A[2] == -1 && A[3] == 0, "");258 259 constexpr auto B = FourCharsVecSize{1, 2, 3, 4} !=260 FourCharsVecSize{4, 3, 3, 1};261 static_assert(B[0] == -1 && B[1] == -1 && B[2] == 0 && B[3] == -1, "");262 263 constexpr auto C = FourCharsVecSize{1, 2, 3, 4} < 3;264 static_assert(C[0] == -1 && C[1] == -1 && C[2] == 0 && C[3] == 0, "");265 266 constexpr auto D = FourCharsVecSize{1, 2, 3, 4} > 3;267 static_assert(D[0] == 0 && D[1] == 0 && D[2] == 0 && D[3] == -1, "");268 269 constexpr auto E = FourCharsVecSize{1, 2, 3, 4} <= 3;270 static_assert(E[0] == -1 && E[1] == -1 && E[2] == -1 && E[3] == 0, "");271 272 constexpr auto F = FourCharsVecSize{1, 2, 3, 4} >= 3;273 static_assert(F[0] == 0 && F[1] == 0 && F[2] == -1 && F[3] == -1, "");274 275 constexpr auto G = FourCharsVecSize{1, 2, 3, 4} == 3;276 static_assert(G[0] == 0 && G[1] == 0 && G[2] == -1 && G[3] == 0, "");277 278 constexpr auto H = FourCharsVecSize{1, 2, 3, 4} != 3;279 static_assert(H[0] == -1 && H[1] == -1 && H[2] == 0 && H[3] == -1, "");280 281 constexpr auto I = FourCharsVecSize{1, 2, 3, 4} &282 FourCharsVecSize{4, 3, 2, 1};283 static_assert(I[0] == 0 && I[1] == 2 && I[2] == 2 && I[3] == 0, "");284 285 constexpr auto J = FourCharsVecSize{1, 2, 3, 4} ^286 FourCharsVecSize { 4, 3, 2, 1 };287 static_assert(J[0] == 5 && J[1] == 1 && J[2] == 1 && J[3] == 5, "");288 289 constexpr auto K = FourCharsVecSize{1, 2, 3, 4} |290 FourCharsVecSize{4, 3, 2, 1};291 static_assert(K[0] == 5 && K[1] == 3 && K[2] == 3 && K[3] == 5, "");292 293 constexpr auto L = FourCharsVecSize{1, 2, 3, 4} & 3;294 static_assert(L[0] == 1 && L[1] == 2 && L[2] == 3 && L[3] == 0, "");295 296 constexpr auto M = FourCharsVecSize{1, 2, 3, 4} ^ 3;297 static_assert(M[0] == 2 && M[1] == 1 && M[2] == 0 && M[3] == 7, "");298 299 constexpr auto N = FourCharsVecSize{1, 2, 3, 4} | 3;300 static_assert(N[0] == 3 && N[1] == 3 && N[2] == 3 && N[3] == 7, "");301 302 constexpr auto O = FourCharsVecSize{5, 0, 6, 0} &&303 FourCharsVecSize{5, 5, 0, 0};304 static_assert(O[0] == 1 && O[1] == 0 && O[2] == 0 && O[3] == 0, "");305 306 constexpr auto P = FourCharsVecSize{5, 0, 6, 0} ||307 FourCharsVecSize{5, 5, 0, 0};308 static_assert(P[0] == 1 && P[1] == 1 && P[2] == 1 && P[3] == 0, "");309 310 constexpr auto Q = FourCharsVecSize{5, 0, 6, 0} && 3;311 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");312 313 constexpr auto R = FourCharsVecSize{5, 0, 6, 0} || 3;314 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");315 316 constexpr auto T = CmpMul(a, b);317 static_assert(T[0] == 108 && T[1] == 18 && T[2] == 56 && T[3] == 72, "");318 319 constexpr auto U = CmpDiv(a, b);320 static_assert(U[0] == 3 && U[1] == 18 && U[2] == 0 && U[3] == 0, "");321 322 constexpr auto V = CmpRem(a, b);323 static_assert(V[0] == 0 && V[1] == 0 && V[2] == 7 && V[3] == 8, "");324 325 constexpr auto X = CmpAdd(a, b);326 static_assert(X[0] == 24 && X[1] == 19 && X[2] == 15 && X[3] == 17, "");327 328 constexpr auto Y = CmpSub(a, b);329 static_assert(Y[0] == 12 && Y[1] == 17 && Y[2] == -1 && Y[3] == -1, "");330 331 constexpr auto InvH = -H;332 static_assert(InvH[0] == 1 && InvH[1] == 1 && InvH[2] == 0 && InvH[3] == 1, "");333 334 constexpr auto Z = CmpLSH(a, InvH);335 static_assert(Z[0] == 36 && Z[1] == 36 && Z[2] == 7 && Z[3] == 16, "");336 337 constexpr auto aa = CmpRSH(a, InvH);338 static_assert(aa[0] == 9 && aa[1] == 9 && aa[2] == 7 && aa[3] == 4, "");339 340 constexpr auto ab = CmpBinAnd(a, b);341 static_assert(ab[0] == 2 && ab[1] == 0 && ab[2] == 0 && ab[3] == 8, "");342 343 constexpr auto ac = CmpBinXOr(a, b);344 static_assert(ac[0] == 20 && ac[1] == 19 && ac[2] == 15 && ac[3] == 1, "");345 346 constexpr auto ad = CmpBinOr(a, b);347 static_assert(ad[0] == 22 && ad[1] == 19 && ad[2] == 15 && ad[3] == 9, "");348 349 constexpr auto ae = ~FourCharsVecSize{1, 2, 10, 20};350 static_assert(ae[0] == -2 && ae[1] == -3 && ae[2] == -11 && ae[3] == -21, "");351 352 constexpr auto af = !FourCharsVecSize{0, 1, 8, -1};353 static_assert(af[0] == -1 && af[1] == 0 && af[2] == 0 && af[3] == 0, "");354}355 356void CharExtVecUsage() {357 constexpr auto a = FourCharsExtVec{6, 3, 2, 1} +358 FourCharsExtVec{12, 15, 5, 7};359 static_assert(a[0] == 18 && a[1] == 18 && a[2] == 7 && a[3] == 8, "");360 361 constexpr auto b = FourCharsExtVec{19, 15, 13, 12} -362 FourCharsExtVec{13, 14, 5, 3};363 static_assert(b[0] == 6 && b[1] == 1 && b[2] == 8 && b[3] == 9, "");364 365 constexpr auto c = FourCharsExtVec{8, 4, 2, 1} *366 FourCharsExtVec{3, 4, 5, 6};367 static_assert(c[0] == 24 && c[1] == 16 && c[2] == 10 && c[3] == 6, "");368 369 constexpr auto d = FourCharsExtVec{12, 12, 10, 10} /370 FourCharsExtVec{6, 4, 5, 2};371 static_assert(d[0] == 2 && d[1] == 3 && d[2] == 2 && d[3] == 5, "");372 373 constexpr auto e = FourCharsExtVec{12, 12, 10, 10} %374 FourCharsExtVec{6, 4, 4, 3};375 static_assert(e[0] == 0 && e[1] == 0 && e[2] == 2 && e[3] == 1, "");376 377 constexpr auto f = FourCharsExtVec{6, 3, 2, 1} + 3;378 static_assert(f[0] == 9 && f[1] == 6 && f[2] == 5 && f[3] == 4, "");379 380 constexpr auto g = FourCharsExtVec{19, 15, 12, 10} - 3;381 static_assert(g[0] == 16 && g[1] == 12 && g[2] == 9 && g[3] == 7, "");382 383 constexpr auto h = FourCharsExtVec{8, 4, 2, 1} * 3;384 static_assert(h[0] == 24 && h[1] == 12 && h[2] == 6 && h[3] == 3, "");385 386 constexpr auto j = FourCharsExtVec{12, 15, 18, 21} / 3;387 static_assert(j[0] == 4 && j[1] == 5 && j[2] == 6 && j[3] == 7, "");388 389 constexpr auto k = FourCharsExtVec{12, 17, 19, 22} % 3;390 static_assert(k[0] == 0 && k[1] == 2 && k[2] == 1 && k[3] == 1, "");391 392 constexpr auto l = 3 + FourCharsExtVec{6, 3, 2, 1};393 static_assert(l[0] == 9 && l[1] == 6 && l[2] == 5 && l[3] == 4, "");394 395 constexpr auto m = 20 - FourCharsExtVec{19, 15, 12, 10};396 static_assert(m[0] == 1 && m[1] == 5 && m[2] == 8 && m[3] == 10, "");397 398 constexpr auto n = 3 * FourCharsExtVec{8, 4, 2, 1};399 static_assert(n[0] == 24 && n[1] == 12 && n[2] == 6 && n[3] == 3, "");400 401 constexpr auto o = 100 / FourCharsExtVec{12, 15, 18, 21};402 static_assert(o[0] == 8 && o[1] == 6 && o[2] == 5 && o[3] == 4, "");403 404 constexpr auto p = 100 % FourCharsExtVec{12, 15, 18, 21};405 static_assert(p[0] == 4 && p[1] == 10 && p[2] == 10 && p[3] == 16, "");406 407 constexpr auto q = FourCharsExtVec{6, 3, 2, 1} << FourCharsVecSize{1, 1, 2, 2};408 static_assert(q[0] == 12 && q[1] == 6 && q[2] == 8 && q[3] == 4, "");409 410 constexpr auto r = FourCharsExtVec{19, 15, 12, 10} >>411 FourCharsExtVec{1, 1, 2, 2};412 static_assert(r[0] == 9 && r[1] == 7 && r[2] == 3 && r[3] == 2, "");413 414 constexpr auto s = FourCharsExtVec{6, 3, 5, 10} << 1;415 static_assert(s[0] == 12 && s[1] == 6 && s[2] == 10 && s[3] == 20, "");416 417 constexpr auto t = FourCharsExtVec{19, 15, 10, 20} >> 1;418 static_assert(t[0] == 9 && t[1] == 7 && t[2] == 5 && t[3] == 10, "");419 420 constexpr auto u = 12 << FourCharsExtVec{1, 2, 3, 3};421 static_assert(u[0] == 24 && u[1] == 48 && u[2] == 96 && u[3] == 96, "");422 423 constexpr auto v = 12 >> FourCharsExtVec{1, 2, 2, 1};424 static_assert(v[0] == 6 && v[1] == 3 && v[2] == 3 && v[3] == 6, "");425 426 constexpr auto w = FourCharsExtVec{1, 2, 3, 4} <427 FourCharsExtVec{4, 3, 2, 1};428 static_assert(w[0] == -1 && w[1] == -1 && w[2] == 0 && w[3] == 0, "");429 430 constexpr auto x = FourCharsExtVec{1, 2, 3, 4} >431 FourCharsExtVec{4, 3, 2, 1};432 static_assert(x[0] == 0 && x[1] == 0 && x[2] == -1 && x[3] == -1, "");433 434 constexpr auto y = FourCharsExtVec{1, 2, 3, 4} <=435 FourCharsExtVec{4, 3, 3, 1};436 static_assert(y[0] == -1 && y[1] == -1 && y[2] == -1 && y[3] == 0, "");437 438 constexpr auto z = FourCharsExtVec{1, 2, 3, 4} >=439 FourCharsExtVec{4, 3, 3, 1};440 static_assert(z[0] == 0 && z[1] == 0 && z[2] == -1 && z[3] == -1, "");441 442 constexpr auto A = FourCharsExtVec{1, 2, 3, 4} ==443 FourCharsExtVec{4, 3, 3, 1};444 static_assert(A[0] == 0 && A[1] == 0 && A[2] == -1 && A[3] == 0, "");445 446 constexpr auto B = FourCharsExtVec{1, 2, 3, 4} !=447 FourCharsExtVec{4, 3, 3, 1};448 static_assert(B[0] == -1 && B[1] == -1 && B[2] == 0 && B[3] == -1, "");449 450 constexpr auto C = FourCharsExtVec{1, 2, 3, 4} < 3;451 static_assert(C[0] == -1 && C[1] == -1 && C[2] == 0 && C[3] == 0, "");452 453 constexpr auto D = FourCharsExtVec{1, 2, 3, 4} > 3;454 static_assert(D[0] == 0 && D[1] == 0 && D[2] == 0 && D[3] == -1, "");455 456 constexpr auto E = FourCharsExtVec{1, 2, 3, 4} <= 3;457 static_assert(E[0] == -1 && E[1] == -1 && E[2] == -1 && E[3] == 0, "");458 459 constexpr auto F = FourCharsExtVec{1, 2, 3, 4} >= 3;460 static_assert(F[0] == 0 && F[1] == 0 && F[2] == -1 && F[3] == -1, "");461 462 constexpr auto G = FourCharsExtVec{1, 2, 3, 4} == 3;463 static_assert(G[0] == 0 && G[1] == 0 && G[2] == -1 && G[3] == 0, "");464 465 constexpr auto H = FourCharsExtVec{1, 2, 3, 4} != 3;466 static_assert(H[0] == -1 && H[1] == -1 && H[2] == 0 && H[3] == -1, "");467 468 constexpr auto I = FourCharsExtVec{1, 2, 3, 4} &469 FourCharsExtVec{4, 3, 2, 1};470 static_assert(I[0] == 0 && I[1] == 2 && I[2] == 2 && I[3] == 0, "");471 472 constexpr auto J = FourCharsExtVec{1, 2, 3, 4} ^473 FourCharsExtVec { 4, 3, 2, 1 };474 static_assert(J[0] == 5 && J[1] == 1 && J[2] == 1 && J[3] == 5, "");475 476 constexpr auto K = FourCharsExtVec{1, 2, 3, 4} |477 FourCharsExtVec{4, 3, 2, 1};478 static_assert(K[0] == 5 && K[1] == 3 && K[2] == 3 && K[3] == 5, "");479 480 constexpr auto L = FourCharsExtVec{1, 2, 3, 4} & 3;481 static_assert(L[0] == 1 && L[1] == 2 && L[2] == 3 && L[3] == 0, "");482 483 constexpr auto M = FourCharsExtVec{1, 2, 3, 4} ^ 3;484 static_assert(M[0] == 2 && M[1] == 1 && M[2] == 0 && M[3] == 7, "");485 486 constexpr auto N = FourCharsExtVec{1, 2, 3, 4} | 3;487 static_assert(N[0] == 3 && N[1] == 3 && N[2] == 3 && N[3] == 7, "");488 489 constexpr auto O = FourCharsExtVec{5, 0, 6, 0} &&490 FourCharsExtVec{5, 5, 0, 0};491 static_assert(O[0] == 1 && O[1] == 0 && O[2] == 0 && O[3] == 0, "");492 493 constexpr auto P = FourCharsExtVec{5, 0, 6, 0} ||494 FourCharsExtVec{5, 5, 0, 0};495 static_assert(P[0] == 1 && P[1] == 1 && P[2] == 1 && P[3] == 0, "");496 497 constexpr auto Q = FourCharsExtVec{5, 0, 6, 0} && 3;498 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");499 500 constexpr auto R = FourCharsExtVec{5, 0, 6, 0} || 3;501 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");502 503 constexpr auto T = CmpMul(a, b);504 static_assert(T[0] == 108 && T[1] == 18 && T[2] == 56 && T[3] == 72, "");505 506 constexpr auto U = CmpDiv(a, b);507 static_assert(U[0] == 3 && U[1] == 18 && U[2] == 0 && U[3] == 0, "");508 509 constexpr auto V = CmpRem(a, b);510 static_assert(V[0] == 0 && V[1] == 0 && V[2] == 7 && V[3] == 8, "");511 512 constexpr auto X = CmpAdd(a, b);513 static_assert(X[0] == 24 && X[1] == 19 && X[2] == 15 && X[3] == 17, "");514 515 constexpr auto Y = CmpSub(a, b);516 static_assert(Y[0] == 12 && Y[1] == 17 && Y[2] == -1 && Y[3] == -1, "");517 518 constexpr auto InvH = -H;519 static_assert(InvH[0] == 1 && InvH[1] == 1 && InvH[2] == 0 && InvH[3] == 1, "");520 521 constexpr auto Z = CmpLSH(a, InvH);522 static_assert(Z[0] == 36 && Z[1] == 36 && Z[2] == 7 && Z[3] == 16, "");523 524 constexpr auto aa = CmpRSH(a, InvH);525 static_assert(aa[0] == 9 && aa[1] == 9 && aa[2] == 7 && aa[3] == 4, "");526 527 constexpr auto ab = CmpBinAnd(a, b);528 static_assert(ab[0] == 2 && ab[1] == 0 && ab[2] == 0 && ab[3] == 8, "");529 530 constexpr auto ac = CmpBinXOr(a, b);531 static_assert(ac[0] == 20 && ac[1] == 19 && ac[2] == 15 && ac[3] == 1, "");532 533 constexpr auto ad = CmpBinOr(a, b);534 static_assert(ad[0] == 22 && ad[1] == 19 && ad[2] == 15 && ad[3] == 9, "");535 536 constexpr auto ae = ~FourCharsExtVec{1, 2, 10, 20};537 static_assert(ae[0] == -2 && ae[1] == -3 && ae[2] == -11 && ae[3] == -21, "");538 539 constexpr auto af = !FourCharsExtVec{0, 1, 8, -1};540 static_assert(af[0] == -1 && af[1] == 0 && af[2] == 0 && af[3] == 0, "");541}542 543void FloatUsage() {544 constexpr auto a = FourFloatsVecSize{6, 3, 2, 1} +545 FourFloatsVecSize{12, 15, 5, 7};546 static_assert(a[0] == 1.800000e+01 && a[1] == 1.800000e+01 && a[2] == 7.000000e+00 && a[3] == 8.000000e+00, "");547 548 constexpr auto b = FourFloatsVecSize{19, 15, 13, 12} -549 FourFloatsVecSize{13, 14, 5, 3};550 static_assert(b[0] == 6.000000e+00 && b[1] == 1.000000e+00 && b[2] == 8.000000e+00 && b[3] == 9.000000e+00, "");551 552 constexpr auto c = FourFloatsVecSize{8, 4, 2, 1} *553 FourFloatsVecSize{3, 4, 5, 6};554 static_assert(c[0] == 2.400000e+01 && c[1] == 1.600000e+01 && c[2] == 1.000000e+01 && c[3] == 6.000000e+00, "");555 556 constexpr auto d = FourFloatsVecSize{12, 12, 10, 10} /557 FourFloatsVecSize{6, 4, 5, 2};558 static_assert(d[0] == 2.000000e+00 && d[1] == 3.000000e+00 && d[2] == 2.000000e+00 && d[3] == 5.000000e+00, "");559 560 constexpr auto f = FourFloatsVecSize{6, 3, 2, 1} + 3;561 static_assert(f[0] == 9.000000e+00 && f[1] == 6.000000e+00 && f[2] == 5.000000e+00 && f[3] == 4.000000e+00, "");562 563 constexpr auto g = FourFloatsVecSize{19, 15, 12, 10} - 3;564 static_assert(g[0] == 1.600000e+01 && g[1] == 1.200000e+01 && g[2] == 9.000000e+00 && g[3] == 7.000000e+00, "");565 566 constexpr auto h = FourFloatsVecSize{8, 4, 2, 1} * 3;567 static_assert(h[0] == 2.400000e+01 && h[1] == 1.200000e+01 && h[2] == 6.000000e+00 && h[3] == 3.000000e+00, "");568 569 constexpr auto j = FourFloatsVecSize{12, 15, 18, 21} / 3;570 static_assert(j[0] == 4.000000e+00 && j[1] == 5.000000e+00 && j[2] == 6.000000e+00 && j[3] == 7.000000e+00, "");571 572 constexpr auto l = 3 + FourFloatsVecSize{6, 3, 2, 1};573 static_assert(l[0] == 9.000000e+00 && l[1] == 6.000000e+00 && l[2] == 5.000000e+00 && l[3] == 4.000000e+00, "");574 575 constexpr auto m = 20 - FourFloatsVecSize{19, 15, 12, 10};576 static_assert(m[0] == 1.000000e+00 && m[1] == 5.000000e+00 && m[2] == 8.000000e+00 && m[3] == 1.000000e+01, "");577 578 constexpr auto n = 3 * FourFloatsVecSize{8, 4, 2, 1};579 static_assert(n[0] == 2.400000e+01 && n[1] == 1.200000e+01 && n[2] == 6.000000e+00 && n[3] == 3.000000e+00, "");580 581 constexpr auto o = 100 / FourFloatsVecSize{12, 15, 18, 21};582 static_assert(CmpF(o[0], 100.0 / 12) && CmpF(o[1], 100.0 / 15) && CmpF(o[2], 100.0 / 18) && CmpF(o[3], 100.0 / 21), "");583 584 constexpr auto w = FourFloatsVecSize{1, 2, 3, 4} <585 FourFloatsVecSize{4, 3, 2, 1};586 static_assert(w[0] == -1 && w[1] == -1 && w[2] == 0 && w[3] == 0, "");587 588 constexpr auto x = FourFloatsVecSize{1, 2, 3, 4} >589 FourFloatsVecSize{4, 3, 2, 1};590 static_assert(x[0] == 0 && x[1] == 0 && x[2] == -1 && x[3] == -1, "");591 592 constexpr auto y = FourFloatsVecSize{1, 2, 3, 4} <=593 FourFloatsVecSize{4, 3, 3, 1};594 static_assert(y[0] == -1 && y[1] == -1 && y[2] == -1 && y[3] == 0, "");595 596 constexpr auto z = FourFloatsVecSize{1, 2, 3, 4} >=597 FourFloatsVecSize{4, 3, 3, 1};598 static_assert(z[0] == 0 && z[1] == 0 && z[2] == -1 && z[3] == -1, "");599 600 constexpr auto A = FourFloatsVecSize{1, 2, 3, 4} ==601 FourFloatsVecSize{4, 3, 3, 1};602 static_assert(A[0] == 0 && A[1] == 0 && A[2] == -1 && A[3] == 0, "");603 604 constexpr auto B = FourFloatsVecSize{1, 2, 3, 4} !=605 FourFloatsVecSize{4, 3, 3, 1};606 static_assert(B[0] == -1 && B[1] == -1 && B[2] == 0 && B[3] == -1, "");607 608 constexpr auto C = FourFloatsVecSize{1, 2, 3, 4} < 3;609 static_assert(C[0] == -1 && C[1] == -1 && C[2] == 0 && C[3] == 0, "");610 611 constexpr auto D = FourFloatsVecSize{1, 2, 3, 4} > 3;612 static_assert(D[0] == 0 && D[1] == 0 && D[2] == 0 && D[3] == -1, "");613 614 constexpr auto E = FourFloatsVecSize{1, 2, 3, 4} <= 3;615 static_assert(E[0] == -1 && E[1] == -1 && E[2] == -1 && E[3] == 0, "");616 617 constexpr auto F = FourFloatsVecSize{1, 2, 3, 4} >= 3;618 static_assert(F[0] == 0 && F[1] == 0 && F[2] == -1 && F[3] == -1, "");619 620 constexpr auto G = FourFloatsVecSize{1, 2, 3, 4} == 3;621 static_assert(G[0] == 0 && G[1] == 0 && G[2] == -1 && G[3] == 0, "");622 623 constexpr auto H = FourFloatsVecSize{1, 2, 3, 4} != 3;624 static_assert(H[0] == -1 && H[1] == -1 && H[2] == 0 && H[3] == -1, "");625 626 constexpr auto O = FourFloatsVecSize{5, 0, 6, 0} &&627 FourFloatsVecSize{5, 5, 0, 0};628 static_assert(O[0] == 1 && O[1] == 0 && O[2] == 0 && O[3] == 0, "");629 630 constexpr auto P = FourFloatsVecSize{5, 0, 6, 0} ||631 FourFloatsVecSize{5, 5, 0, 0};632 static_assert(P[0] == 1 && P[1] == 1 && P[2] == 1 && P[3] == 0, "");633 634 constexpr auto Q = FourFloatsVecSize{5, 0, 6, 0} && 3;635 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");636 637 constexpr auto R = FourFloatsVecSize{5, 0, 6, 0} || 3;638 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");639 640 constexpr auto T = CmpMul(a, b);641 static_assert(T[0] == 1.080000e+02 && T[1] == 1.800000e+01 && T[2] == 5.600000e+01 && T[3] == 7.200000e+01, "");642 643 constexpr auto U = CmpDiv(a, b);644 static_assert(CmpF(U[0], a[0] / b[0]) && CmpF(U[1], a[1] / b[1]) && CmpF(U[2], a[2] / b[2]) && CmpF(U[3], a[3] / b[3]), "");645 646 constexpr auto X = CmpAdd(a, b);647 static_assert(X[0] == 2.400000e+01 && X[1] == 1.900000e+01 && X[2] == 1.500000e+01 && X[3] == 1.700000e+01, "");648 649 constexpr auto Y = CmpSub(a, b);650 static_assert(Y[0] == 1.200000e+01 && Y[1] == 1.700000e+01 && Y[2] == -1.000000e+00 && Y[3] == -1.000000e+00, "");651 652 constexpr auto Z = -Y;653 static_assert(Z[0] == -1.200000e+01 && Z[1] == -1.700000e+01 && Z[2] == 1.000000e+00 && Z[3] == 1.000000e+00, "");654 655 // Operator ~ is illegal on floats.656 constexpr auto ae = ~FourFloatsVecSize{0, 1, 8, -1}; // expected-error {{invalid argument type}}657 658 constexpr auto af = !FourFloatsVecSize{0, 1, 8, -1};659 static_assert(af[0] == -1 && af[1] == 0 && af[2] == 0 && af[3] == 0, "");660}661 662void FloatVecUsage() {663 constexpr auto a = FourFloatsVecSize{6, 3, 2, 1} +664 FourFloatsVecSize{12, 15, 5, 7};665 static_assert(a[0] == 1.800000e+01 && a[1] == 1.800000e+01 && a[2] == 7.000000e+00 && a[3] == 8.000000e+00, "");666 667 constexpr auto b = FourFloatsVecSize{19, 15, 13, 12} -668 FourFloatsVecSize{13, 14, 5, 3};669 static_assert(b[0] == 6.000000e+00 && b[1] == 1.000000e+00 && b[2] == 8.000000e+00 && b[3] == 9.000000e+00, "");670 671 constexpr auto c = FourFloatsVecSize{8, 4, 2, 1} *672 FourFloatsVecSize{3, 4, 5, 6};673 static_assert(c[0] == 2.400000e+01 && c[1] == 1.600000e+01 && c[2] == 1.000000e+01 && c[3] == 6.000000e+00, "");674 675 constexpr auto d = FourFloatsVecSize{12, 12, 10, 10} /676 FourFloatsVecSize{6, 4, 5, 2};677 static_assert(d[0] == 2.000000e+00 && d[1] == 3.000000e+00 && d[2] == 2.000000e+00 && d[3] == 5.000000e+00, "");678 679 constexpr auto f = FourFloatsVecSize{6, 3, 2, 1} + 3;680 static_assert(f[0] == 9.000000e+00 && f[1] == 6.000000e+00 && f[2] == 5.000000e+00 && f[3] == 4.000000e+00, "");681 682 constexpr auto g = FourFloatsVecSize{19, 15, 12, 10} - 3;683 static_assert(g[0] == 1.600000e+01 && g[1] == 1.200000e+01 && g[2] == 9.000000e+00 && g[3] == 7.000000e+00, "");684 685 constexpr auto h = FourFloatsVecSize{8, 4, 2, 1} * 3;686 static_assert(h[0] == 2.400000e+01 && h[1] == 1.200000e+01 && h[2] == 6.000000e+00 && h[3] == 3.000000e+00, "");687 688 constexpr auto j = FourFloatsVecSize{12, 15, 18, 21} / 3;689 static_assert(j[0] == 4.000000e+00 && j[1] == 5.000000e+00 && j[2] == 6.000000e+00 && j[3] == 7.000000e+00, "");690 691 constexpr auto l = 3 + FourFloatsVecSize{6, 3, 2, 1};692 static_assert(l[0] == 9.000000e+00 && l[1] == 6.000000e+00 && l[2] == 5.000000e+00 && l[3] == 4.000000e+00, "");693 694 constexpr auto m = 20 - FourFloatsVecSize{19, 15, 12, 10};695 static_assert(m[0] == 1.000000e+00 && m[1] == 5.000000e+00 && m[2] == 8.000000e+00 && m[3] == 1.000000e+01, "");696 697 constexpr auto n = 3 * FourFloatsVecSize{8, 4, 2, 1};698 static_assert(n[0] == 2.400000e+01 && n[1] == 1.200000e+01 && n[2] == 6.000000e+00 && n[3] == 3.000000e+00, "");699 700 constexpr auto o = 100 / FourFloatsVecSize{12, 15, 18, 21};701 static_assert(CmpF(o[0], 100.0 / 12) && CmpF(o[1], 100.0 / 15) && CmpF(o[2], 100.0 / 18) && CmpF(o[3], 100.0 / 21), "");702 703 constexpr auto w = FourFloatsVecSize{1, 2, 3, 4} <704 FourFloatsVecSize{4, 3, 2, 1};705 static_assert(w[0] == -1 && w[1] == -1 && w[2] == 0 && w[3] == 0, "");706 707 constexpr auto x = FourFloatsVecSize{1, 2, 3, 4} >708 FourFloatsVecSize{4, 3, 2, 1};709 static_assert(x[0] == 0 && x[1] == 0 && x[2] == -1 && x[2] == -1, "");710 711 constexpr auto y = FourFloatsVecSize{1, 2, 3, 4} <=712 FourFloatsVecSize{4, 3, 3, 1};713 static_assert(y[0] == -1 && y[1] == -1 && y[2] == -1 && y[3] == 0, "");714 715 constexpr auto z = FourFloatsVecSize{1, 2, 3, 4} >=716 FourFloatsVecSize{4, 3, 3, 1};717 static_assert(z[0] == 0 && z[1] == 0 && z[2] == -1 && z[3] == -1, "");718 719 constexpr auto A = FourFloatsVecSize{1, 2, 3, 4} ==720 FourFloatsVecSize{4, 3, 3, 1};721 static_assert(A[0] == 0 && A[1] == 0 && A[2] == -1 && A[3] == 0, "");722 723 constexpr auto B = FourFloatsVecSize{1, 2, 3, 4} !=724 FourFloatsVecSize{4, 3, 3, 1};725 static_assert(B[0] == -1 && B[1] == -1 && B[2] == 0 && B[3] == -1, "");726 727 constexpr auto C = FourFloatsVecSize{1, 2, 3, 4} < 3;728 static_assert(C[0] == -1 && C[1] == -1 && C[2] == 0 && C[3] == 0, "");729 730 constexpr auto D = FourFloatsVecSize{1, 2, 3, 4} > 3;731 static_assert(D[0] == 0 && D[1] == 0 && D[2] == 0 && D[3] == -1, "");732 733 constexpr auto E = FourFloatsVecSize{1, 2, 3, 4} <= 3;734 static_assert(E[0] == -1 && E[1] == -1 && E[2] == -1 && E[3] == 0, "");735 736 constexpr auto F = FourFloatsVecSize{1, 2, 3, 4} >= 3;737 static_assert(F[0] == 0 && F[1] == 0 && F[2] == -1 && F[3] == -1, "");738 739 constexpr auto G = FourFloatsVecSize{1, 2, 3, 4} == 3;740 static_assert(G[0] == 0 && G[1] == 0 && G[2] == -1 && G[3] == 0, "");741 742 constexpr auto H = FourFloatsVecSize{1, 2, 3, 4} != 3;743 static_assert(H[0] == -1 && H[1] == -1 && H[2] == 0 && H[3] == -1, "");744 745 constexpr auto O = FourFloatsVecSize{5, 0, 6, 0} &&746 FourFloatsVecSize{5, 5, 0, 0};747 static_assert(O[0] == 1 && O[1] == 0 && O[2] == 0 && O[3] == 0, "");748 749 constexpr auto P = FourFloatsVecSize{5, 0, 6, 0} ||750 FourFloatsVecSize{5, 5, 0, 0};751 static_assert(P[0] == 1 && P[1] == 1 && P[2] == 1 && P[3] == 0, "");752 753 constexpr auto Q = FourFloatsVecSize{5, 0, 6, 0} && 3;754 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");755 756 constexpr auto R = FourFloatsVecSize{5, 0, 6, 0} || 3;757 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");758 759 constexpr auto T = CmpMul(a, b);760 static_assert(T[0] == 1.080000e+02 && T[1] == 1.800000e+01 && T[2] == 5.600000e+01 && T[3] == 7.200000e+01, "");761 762 constexpr auto U = CmpDiv(a, b);763 static_assert(CmpF(U[0], a[0] / b[0]) && CmpF(U[1], a[1] / b[1]) && CmpF(U[2], a[2] / b[2]) && CmpF(U[3], a[3] / b[3]), "");764 765 constexpr auto X = CmpAdd(a, b);766 static_assert(X[0] == 2.400000e+01 && X[1] == 1.900000e+01 && X[2] == 1.500000e+01 && X[3] == 1.700000e+01, "");767 768 constexpr auto Y = CmpSub(a, b);769 static_assert(Y[0] == 1.200000e+01 && Y[1] == 1.700000e+01 && Y[2] == -1.000000e+00 && Y[3] == -1.000000e+00, "");770 771 constexpr auto Z = -Y;772 static_assert(Z[0] == -1.200000e+01 && Z[1] == -1.700000e+01 && Z[2] == 1.000000e+00 && Z[3] == 1.000000e+00, "");773 774 // Operator ~ is illegal on floats.775 constexpr auto ae = ~FourFloatsVecSize{0, 1, 8, -1}; // expected-error {{invalid argument type}}776 777 constexpr auto af = !FourFloatsVecSize{0, 1, 8, -1};778 static_assert(af[0] == -1 && af[1] == 0 && af[2] == 0 && af[3] == 0, "");779}780 781void I128Usage() {782 constexpr auto a = FourI128VecSize{1, 2, 3, 4};783 static_assert(a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4, "");784 785 constexpr auto a1 = FourI128VecSize{5, 0, 6, 0} && FourI128VecSize{5, 5, 0, 0};786 static_assert(a1[0] == 1 && a1[1] == 0 && a1[2] == 0 && a1[3] == 0, "");787 788 constexpr auto a2 = FourI128VecSize{5, 0, 6, 0} || FourI128VecSize{5, 5, 0, 0};789 static_assert(a2[0] == 1 && a2[1] == 1 && a2[2] == 1 && a2[3] == 0, "");790 791 constexpr auto Q = FourI128VecSize{5, 0, 6, 0} && 3;792 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");793 794 constexpr auto R = FourI128VecSize{5, 0, 6, 0} || 3;795 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");796 797 constexpr auto b = a < 3;798 static_assert(b[0] == -1 && b[1] == -1 && b[2] == 0 && b[3] == 0, "");799 800 constexpr auto c = ~FourI128VecSize{1, 2, 10, 20};801 static_assert(c[0] == -2 && c[1] == -3 && c[2] == -11 && c[3] == -21, "");802 803 constexpr auto d = !FourI128VecSize{0, 1, 8, -1};804 static_assert(d[0] == -1 && d[1] == 0 && d[2] == 0 && d[3] == 0, "");805}806 807void I128VecUsage() {808 constexpr auto a = FourI128ExtVec{1, 2, 3, 4};809 static_assert(a[0] == 1 && a[1] == 2 && a[2] == 3 && a[3] == 4, "");810 811 constexpr auto a1 = FourI128ExtVec{5, 0, 6, 0} && FourI128ExtVec{5, 5, 0, 0};812 static_assert(a1[0] == 1 && a1[1] == 0 && a1[2] == 0 && a1[3] == 0, "");813 814 constexpr auto a2 = FourI128ExtVec{5, 0, 6, 0} || FourI128ExtVec{5, 5, 0, 0};815 static_assert(a2[0] == 1 && a2[1] == 1 && a2[2] == 1 && a2[3] == 0, "");816 817 constexpr auto Q = FourI128ExtVec{5, 0, 6, 0} && 3;818 static_assert(Q[0] == 1 && Q[1] == 0 && Q[2] == 1 && Q[3] == 0, "");819 820 constexpr auto R = FourI128ExtVec{5, 0, 6, 0} || 3;821 static_assert(R[0] == 1 && R[1] == 1 && R[2] == 1 && R[3] == 1, "");822 823 constexpr auto b = a < 3;824 static_assert(b[0] == -1 && b[1] == -1 && b[2] == 0 && b[3] == 0, "");825 826 constexpr auto c = ~FourI128ExtVec{1, 2, 10, 20};827 static_assert(c[0] == -2 && c[1] == -3 && c[2] == -11 && c[3] == -21, "");828 829 constexpr auto d = !FourI128ExtVec{0, 1, 8, -1};830 static_assert(d[0] == -1 && d[1] == 0 && d[2] == 0 && d[3] == 0, "");831}832 833using FourBoolsExtVec __attribute__((ext_vector_type(4))) = bool;834void BoolVecUsage() {835 constexpr auto a = FourBoolsExtVec{true, false, true, false} <836 FourBoolsExtVec{false, false, true, true};837 static_assert(a[0] == false && a[1] == false && a[2] == false && a[3] == true, "");838 839 constexpr auto b = FourBoolsExtVec{true, false, true, false} <=840 FourBoolsExtVec{false, false, true, true};841 static_assert(b[0] == false && b[1] == true && b[2] == true && b[3] == true, "");842 843 constexpr auto c = FourBoolsExtVec{true, false, true, false} ==844 FourBoolsExtVec{false, false, true, true};845 static_assert(c[0] == false && c[1] == true && c[2] == true && c[3] == false, "");846 847 constexpr auto d = FourBoolsExtVec{true, false, true, false} !=848 FourBoolsExtVec{false, false, true, true};849 static_assert(d[0] == true && d[1] == false && d[2] == false && d[3] == true, "");850 851 constexpr auto e = FourBoolsExtVec{true, false, true, false} >=852 FourBoolsExtVec{false, false, true, true};853 static_assert(e[0] == true && e[1] == true && e[2] == true && e[3] == false, "");854 855 constexpr auto f = FourBoolsExtVec{true, false, true, false} >856 FourBoolsExtVec{false, false, true, true};857 static_assert(f[0] == true && f[1] == false && f[2] == false && f[3] == false, "");858 859 constexpr auto g = FourBoolsExtVec{true, false, true, false} &860 FourBoolsExtVec{false, false, true, true};861 static_assert(g[0] == false && g[1] == false && g[2] == true && g[3] == false, "");862 863 constexpr auto h = FourBoolsExtVec{true, false, true, false} |864 FourBoolsExtVec{false, false, true, true};865 static_assert(h[0] == true && h[1] == false && h[2] == true && h[3] == true, "");866 867 constexpr auto i = FourBoolsExtVec{true, false, true, false} ^868 FourBoolsExtVec { false, false, true, true };869 static_assert(i[0] == true && i[1] == false && i[2] == false && i[3] == true, "");870 871 constexpr auto j = !FourBoolsExtVec{true, false, true, false};872 static_assert(j[0] == false && j[1] == true && j[2] == false && j[3] == true, "");873 874 constexpr auto k = ~FourBoolsExtVec{true, false, true, false};875 static_assert(k[0] == false && k[1] == true && k[2] == false && k[3] == true, "");876}877 878using EightBoolsExtVec __attribute__((ext_vector_type(8))) = bool;879void BoolVecShuffle() {880 constexpr EightBoolsExtVec a = __builtin_shufflevector(881 FourBoolsExtVec{}, FourBoolsExtVec{}, 0, 1, 2, 3, 4, 5, 6, 7);882}883