1025 lines · cpp
1// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension %s2// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64-unknown-linux %s3// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64le-unknown-linux %s4 5// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension %s -fexperimental-new-constant-interpreter6// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64-unknown-linux %s -fexperimental-new-constant-interpreter7// RUN: %clang_cc1 -verify -std=c++2a -fsyntax-only -Wno-bit-int-extension -triple ppc64le-unknown-linux %s -fexperimental-new-constant-interpreter8 9#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__10#define LITTLE_END 111#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__12#define LITTLE_END 013#else14#error "huh?"15#endif16 17// We also support _BitInt as long as it is >=8 and a power of 2.18typedef _BitInt(8) BitInt8;19typedef _BitInt(32) BitInt32;20typedef _BitInt(128) BitInt128;21 22typedef double vector4double __attribute__((__vector_size__(32)));23typedef float vector4float __attribute__((__vector_size__(16)));24typedef long long vector4long __attribute__((__vector_size__(32)));25typedef int vector4int __attribute__((__vector_size__(16)));26typedef unsigned long long vector4ulong __attribute__((__vector_size__(32)));27typedef unsigned int vector4uint __attribute__((__vector_size__(16)));28typedef short vector4short __attribute__((__vector_size__(8)));29typedef char vector4char __attribute__((__vector_size__(4)));30typedef unsigned char vector4uchar __attribute__((__vector_size__(4)));31typedef BitInt8 vector4BitInt8 __attribute__((__vector_size__(4)));32typedef BitInt32 vector4BitInt32 __attribute__((__vector_size__(16)));33typedef BitInt128 vector4BitInt128 __attribute__((__vector_size__(64)));34typedef double vector8double __attribute__((__vector_size__(64)));35typedef float vector8float __attribute__((__vector_size__(32)));36typedef long long vector8long __attribute__((__vector_size__(64)));37typedef int vector8int __attribute__((__vector_size__(32)));38typedef short vector8short __attribute__((__vector_size__(16)));39typedef char vector8char __attribute__((__vector_size__(8)));40typedef BitInt8 vector8BitInt8 __attribute__((__vector_size__(8)));41typedef BitInt32 vector8BitInt32 __attribute__((__vector_size__(32)));42typedef BitInt128 vector8BitInt128 __attribute__((__vector_size__(128)));43 44#define CHECK_NUM(__size, __typeFrom, __typeTo, ...) \45 constexpr vector##__size##__typeTo \46 from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var = \47 __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__}, \48 vector##__size##__typeTo);49#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...) \50 CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__) \51 CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__) \52 CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) \53 CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__) \54 CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__) \55 CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__) \56 CHECK_NUM(__size, __typeFrom, BitInt8, __VA_ARGS__) \57 CHECK_NUM(__size, __typeFrom, BitInt32, __VA_ARGS__) \58 CHECK_NUM(__size, __typeFrom, BitInt128, __VA_ARGS__) \59 static_assert( \60 __builtin_bit_cast( \61 unsigned, \62 __builtin_shufflevector( \63 from_vector##__size##__typeFrom##_to_vector##__size##char_var, \64 from_vector##__size##__typeFrom##_to_vector##__size##char_var, \65 0, 1, 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203)); \66 static_assert( \67 __builtin_bit_cast( \68 unsigned long long, \69 __builtin_shufflevector( \70 from_vector##__size##__typeFrom##_to_vector##__size##short_var, \71 from_vector##__size##__typeFrom##_to_vector##__size##short_var, \72 0, 1, 2, 3)) == \73 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));74 75#define CHECK_ALL_COMBINATIONS(__size, ...) \76 CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__) \77 CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__) \78 CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__) \79 CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) \80 CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__) \81 CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__) \82 CHECK_TO_ALL_TYPES(__size, BitInt8, __VA_ARGS__) \83 CHECK_TO_ALL_TYPES(__size, BitInt32, __VA_ARGS__) \84 CHECK_TO_ALL_TYPES(__size, BitInt128, __VA_ARGS__)85 86// The result below is expanded from these macros. Use them to autogenerate the87// test cases below.88// CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);89// CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);90 91constexpr vector4double from_vector4double_to_vector4double_var =92 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4double);93constexpr vector4float from_vector4double_to_vector4float_var =94 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4float);95constexpr vector4long from_vector4double_to_vector4long_var =96 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4long);97constexpr vector4int from_vector4double_to_vector4int_var =98 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4int);99constexpr vector4short from_vector4double_to_vector4short_var =100 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4short);101constexpr vector4char from_vector4double_to_vector4char_var =102 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4char);103constexpr vector4BitInt8 from_vector4double_to_vector4BitInt8_var =104 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4BitInt8);105constexpr vector4BitInt32 from_vector4double_to_vector4BitInt32_var =106 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4BitInt32);107constexpr vector4BitInt128 from_vector4double_to_vector4BitInt128_var =108 __builtin_convertvector((vector4double){0, 1, 2, 3}, vector4BitInt128);109static_assert(__builtin_bit_cast(110 unsigned,111 __builtin_shufflevector(from_vector4double_to_vector4char_var,112 from_vector4double_to_vector4char_var,113 0, 1, 2, 3)) ==114 (LITTLE_END ? 0x03020100 : 0x00010203));115static_assert(__builtin_bit_cast(unsigned long long,116 __builtin_shufflevector(117 from_vector4double_to_vector4short_var,118 from_vector4double_to_vector4short_var, 0,119 1, 2, 3)) ==120 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));121constexpr vector4double from_vector4float_to_vector4double_var =122 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4double);123constexpr vector4float from_vector4float_to_vector4float_var =124 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4float);125constexpr vector4long from_vector4float_to_vector4long_var =126 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4long);127constexpr vector4int from_vector4float_to_vector4int_var =128 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4int);129constexpr vector4short from_vector4float_to_vector4short_var =130 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4short);131constexpr vector4char from_vector4float_to_vector4char_var =132 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4char);133constexpr vector4BitInt8 from_vector4float_to_vector4BitInt8_var =134 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4BitInt8);135constexpr vector4BitInt32 from_vector4float_to_vector4BitInt32_var =136 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4BitInt32);137constexpr vector4BitInt128 from_vector4float_to_vector4BitInt128_var =138 __builtin_convertvector((vector4float){0, 1, 2, 3}, vector4BitInt128);139static_assert(__builtin_bit_cast(unsigned,140 __builtin_shufflevector(141 from_vector4float_to_vector4char_var,142 from_vector4float_to_vector4char_var, 0, 1,143 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));144static_assert(__builtin_bit_cast(145 unsigned long long,146 __builtin_shufflevector(from_vector4float_to_vector4short_var,147 from_vector4float_to_vector4short_var,148 0, 1, 2, 3)) ==149 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));150constexpr vector4double from_vector4long_to_vector4double_var =151 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4double);152constexpr vector4float from_vector4long_to_vector4float_var =153 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4float);154constexpr vector4long from_vector4long_to_vector4long_var =155 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4long);156constexpr vector4int from_vector4long_to_vector4int_var =157 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4int);158constexpr vector4short from_vector4long_to_vector4short_var =159 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4short);160constexpr vector4char from_vector4long_to_vector4char_var =161 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4char);162constexpr vector4BitInt8 from_vector4long_to_vector4BitInt8_var =163 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4BitInt8);164constexpr vector4BitInt32 from_vector4long_to_vector4BitInt32_var =165 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4BitInt32);166constexpr vector4BitInt128 from_vector4long_to_vector4BitInt128_var =167 __builtin_convertvector((vector4long){0, 1, 2, 3}, vector4BitInt128);168static_assert(__builtin_bit_cast(unsigned,169 __builtin_shufflevector(170 from_vector4long_to_vector4char_var,171 from_vector4long_to_vector4char_var, 0, 1,172 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));173static_assert(__builtin_bit_cast(174 unsigned long long,175 __builtin_shufflevector(from_vector4long_to_vector4short_var,176 from_vector4long_to_vector4short_var,177 0, 1, 2, 3)) ==178 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));179constexpr vector4double from_vector4int_to_vector4double_var =180 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4double);181constexpr vector4float from_vector4int_to_vector4float_var =182 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4float);183constexpr vector4long from_vector4int_to_vector4long_var =184 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4long);185constexpr vector4int from_vector4int_to_vector4int_var =186 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4int);187constexpr vector4short from_vector4int_to_vector4short_var =188 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4short);189constexpr vector4char from_vector4int_to_vector4char_var =190 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4char);191constexpr vector4BitInt8 from_vector4int_to_vector4BitInt8_var =192 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4BitInt8);193constexpr vector4BitInt32 from_vector4int_to_vector4BitInt32_var =194 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4BitInt32);195constexpr vector4BitInt128 from_vector4int_to_vector4BitInt128_var =196 __builtin_convertvector((vector4int){0, 1, 2, 3}, vector4BitInt128);197static_assert(__builtin_bit_cast(unsigned,198 __builtin_shufflevector(199 from_vector4int_to_vector4char_var,200 from_vector4int_to_vector4char_var, 0, 1,201 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));202static_assert(__builtin_bit_cast(203 unsigned long long,204 __builtin_shufflevector(from_vector4int_to_vector4short_var,205 from_vector4int_to_vector4short_var,206 0, 1, 2, 3)) ==207 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));208constexpr vector4double from_vector4short_to_vector4double_var =209 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4double);210constexpr vector4float from_vector4short_to_vector4float_var =211 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4float);212constexpr vector4long from_vector4short_to_vector4long_var =213 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4long);214constexpr vector4int from_vector4short_to_vector4int_var =215 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4int);216constexpr vector4short from_vector4short_to_vector4short_var =217 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4short);218constexpr vector4char from_vector4short_to_vector4char_var =219 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4char);220constexpr vector4BitInt8 from_vector4short_to_vector4BitInt8_var =221 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4BitInt8);222constexpr vector4BitInt32 from_vector4short_to_vector4BitInt32_var =223 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4BitInt32);224constexpr vector4BitInt128 from_vector4short_to_vector4BitInt128_var =225 __builtin_convertvector((vector4short){0, 1, 2, 3}, vector4BitInt128);226static_assert(__builtin_bit_cast(unsigned,227 __builtin_shufflevector(228 from_vector4short_to_vector4char_var,229 from_vector4short_to_vector4char_var, 0, 1,230 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));231static_assert(__builtin_bit_cast(232 unsigned long long,233 __builtin_shufflevector(from_vector4short_to_vector4short_var,234 from_vector4short_to_vector4short_var,235 0, 1, 2, 3)) ==236 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));237constexpr vector4double from_vector4char_to_vector4double_var =238 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4double);239constexpr vector4float from_vector4char_to_vector4float_var =240 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4float);241constexpr vector4long from_vector4char_to_vector4long_var =242 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4long);243constexpr vector4int from_vector4char_to_vector4int_var =244 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4int);245constexpr vector4short from_vector4char_to_vector4short_var =246 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4short);247constexpr vector4char from_vector4char_to_vector4char_var =248 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4char);249constexpr vector4BitInt8 from_vector4char_to_vector4BitInt8_var =250 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4BitInt8);251constexpr vector4BitInt32 from_vector4char_to_vector4BitInt32_var =252 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4BitInt32);253constexpr vector4BitInt128 from_vector4char_to_vector4BitInt128_var =254 __builtin_convertvector((vector4char){0, 1, 2, 3}, vector4BitInt128);255static_assert(__builtin_bit_cast(unsigned,256 __builtin_shufflevector(257 from_vector4char_to_vector4char_var,258 from_vector4char_to_vector4char_var, 0, 1,259 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));260static_assert(__builtin_bit_cast(261 unsigned long long,262 __builtin_shufflevector(from_vector4char_to_vector4short_var,263 from_vector4char_to_vector4short_var,264 0, 1, 2, 3)) ==265 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));266constexpr vector4double from_vector4BitInt8_to_vector4double_var =267 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4double);268constexpr vector4float from_vector4BitInt8_to_vector4float_var =269 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4float);270constexpr vector4long from_vector4BitInt8_to_vector4long_var =271 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4long);272constexpr vector4int from_vector4BitInt8_to_vector4int_var =273 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4int);274constexpr vector4short from_vector4BitInt8_to_vector4short_var =275 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4short);276constexpr vector4char from_vector4BitInt8_to_vector4char_var =277 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4char);278constexpr vector4BitInt8 from_vector4BitInt8_to_vector4BitInt8_var =279 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4BitInt8);280constexpr vector4BitInt32 from_vector4BitInt8_to_vector4BitInt32_var =281 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4BitInt32);282constexpr vector4BitInt128 from_vector4BitInt8_to_vector4BitInt128_var =283 __builtin_convertvector((vector4BitInt8){0, 1, 2, 3}, vector4BitInt128);284static_assert(__builtin_bit_cast(unsigned,285 __builtin_shufflevector(286 from_vector4BitInt8_to_vector4char_var,287 from_vector4BitInt8_to_vector4char_var, 0,288 1, 2, 3)) ==289 (LITTLE_END ? 0x03020100 : 0x00010203));290static_assert(__builtin_bit_cast(unsigned long long,291 __builtin_shufflevector(292 from_vector4BitInt8_to_vector4short_var,293 from_vector4BitInt8_to_vector4short_var, 0,294 1, 2, 3)) ==295 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));296constexpr vector4double from_vector4BitInt32_to_vector4double_var =297 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4double);298constexpr vector4float from_vector4BitInt32_to_vector4float_var =299 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4float);300constexpr vector4long from_vector4BitInt32_to_vector4long_var =301 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4long);302constexpr vector4int from_vector4BitInt32_to_vector4int_var =303 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4int);304constexpr vector4short from_vector4BitInt32_to_vector4short_var =305 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4short);306constexpr vector4char from_vector4BitInt32_to_vector4char_var =307 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4char);308constexpr vector4BitInt8 from_vector4BitInt32_to_vector4BitInt8_var =309 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4BitInt8);310constexpr vector4BitInt32 from_vector4BitInt32_to_vector4BitInt32_var =311 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4BitInt32);312constexpr vector4BitInt128 from_vector4BitInt32_to_vector4BitInt128_var =313 __builtin_convertvector((vector4BitInt32){0, 1, 2, 3}, vector4BitInt128);314static_assert(__builtin_bit_cast(unsigned,315 __builtin_shufflevector(316 from_vector4BitInt32_to_vector4char_var,317 from_vector4BitInt32_to_vector4char_var, 0,318 1, 2, 3)) ==319 (LITTLE_END ? 0x03020100 : 0x00010203));320static_assert(__builtin_bit_cast(unsigned long long,321 __builtin_shufflevector(322 from_vector4BitInt32_to_vector4short_var,323 from_vector4BitInt32_to_vector4short_var,324 0, 1, 2, 3)) ==325 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));326constexpr vector4double from_vector4BitInt128_to_vector4double_var =327 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4double);328constexpr vector4float from_vector4BitInt128_to_vector4float_var =329 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4float);330constexpr vector4long from_vector4BitInt128_to_vector4long_var =331 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4long);332constexpr vector4int from_vector4BitInt128_to_vector4int_var =333 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4int);334constexpr vector4short from_vector4BitInt128_to_vector4short_var =335 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4short);336constexpr vector4char from_vector4BitInt128_to_vector4char_var =337 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4char);338constexpr vector4BitInt8 from_vector4BitInt128_to_vector4BitInt8_var =339 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4BitInt8);340constexpr vector4BitInt32 from_vector4BitInt128_to_vector4BitInt32_var =341 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4BitInt32);342constexpr vector4BitInt128 from_vector4BitInt128_to_vector4BitInt128_var =343 __builtin_convertvector((vector4BitInt128){0, 1, 2, 3}, vector4BitInt128);344static_assert(__builtin_bit_cast(unsigned,345 __builtin_shufflevector(346 from_vector4BitInt128_to_vector4char_var,347 from_vector4BitInt128_to_vector4char_var,348 0, 1, 2, 3)) ==349 (LITTLE_END ? 0x03020100 : 0x00010203));350static_assert(__builtin_bit_cast(unsigned long long,351 __builtin_shufflevector(352 from_vector4BitInt128_to_vector4short_var,353 from_vector4BitInt128_to_vector4short_var,354 0, 1, 2, 3)) ==355 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));356;357constexpr vector8double from_vector8double_to_vector8double_var =358 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},359 vector8double);360constexpr vector8float from_vector8double_to_vector8float_var =361 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},362 vector8float);363constexpr vector8long from_vector8double_to_vector8long_var =364 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},365 vector8long);366constexpr vector8int from_vector8double_to_vector8int_var =367 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},368 vector8int);369constexpr vector8short from_vector8double_to_vector8short_var =370 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},371 vector8short);372constexpr vector8char from_vector8double_to_vector8char_var =373 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},374 vector8char);375constexpr vector8BitInt8 from_vector8double_to_vector8BitInt8_var =376 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},377 vector8BitInt8);378constexpr vector8BitInt32 from_vector8double_to_vector8BitInt32_var =379 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},380 vector8BitInt32);381constexpr vector8BitInt128 from_vector8double_to_vector8BitInt128_var =382 __builtin_convertvector((vector8double){0, 1, 2, 3, 4, 5, 6, 7},383 vector8BitInt128);384static_assert(__builtin_bit_cast(385 unsigned,386 __builtin_shufflevector(from_vector8double_to_vector8char_var,387 from_vector8double_to_vector8char_var,388 0, 1, 2, 3)) ==389 (LITTLE_END ? 0x03020100 : 0x00010203));390static_assert(__builtin_bit_cast(unsigned long long,391 __builtin_shufflevector(392 from_vector8double_to_vector8short_var,393 from_vector8double_to_vector8short_var, 0,394 1, 2, 3)) ==395 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));396constexpr vector8double from_vector8float_to_vector8double_var =397 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},398 vector8double);399constexpr vector8float from_vector8float_to_vector8float_var =400 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},401 vector8float);402constexpr vector8long from_vector8float_to_vector8long_var =403 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},404 vector8long);405constexpr vector8int from_vector8float_to_vector8int_var =406 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7}, vector8int);407constexpr vector8short from_vector8float_to_vector8short_var =408 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},409 vector8short);410constexpr vector8char from_vector8float_to_vector8char_var =411 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},412 vector8char);413constexpr vector8BitInt8 from_vector8float_to_vector8BitInt8_var =414 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},415 vector8BitInt8);416constexpr vector8BitInt32 from_vector8float_to_vector8BitInt32_var =417 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},418 vector8BitInt32);419constexpr vector8BitInt128 from_vector8float_to_vector8BitInt128_var =420 __builtin_convertvector((vector8float){0, 1, 2, 3, 4, 5, 6, 7},421 vector8BitInt128);422static_assert(__builtin_bit_cast(unsigned,423 __builtin_shufflevector(424 from_vector8float_to_vector8char_var,425 from_vector8float_to_vector8char_var, 0, 1,426 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));427static_assert(__builtin_bit_cast(428 unsigned long long,429 __builtin_shufflevector(from_vector8float_to_vector8short_var,430 from_vector8float_to_vector8short_var,431 0, 1, 2, 3)) ==432 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));433constexpr vector8double from_vector8long_to_vector8double_var =434 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},435 vector8double);436constexpr vector8float from_vector8long_to_vector8float_var =437 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},438 vector8float);439constexpr vector8long from_vector8long_to_vector8long_var =440 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7}, vector8long);441constexpr vector8int from_vector8long_to_vector8int_var =442 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7}, vector8int);443constexpr vector8short from_vector8long_to_vector8short_var =444 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},445 vector8short);446constexpr vector8char from_vector8long_to_vector8char_var =447 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7}, vector8char);448constexpr vector8BitInt8 from_vector8long_to_vector8BitInt8_var =449 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},450 vector8BitInt8);451constexpr vector8BitInt32 from_vector8long_to_vector8BitInt32_var =452 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},453 vector8BitInt32);454constexpr vector8BitInt128 from_vector8long_to_vector8BitInt128_var =455 __builtin_convertvector((vector8long){0, 1, 2, 3, 4, 5, 6, 7},456 vector8BitInt128);457static_assert(__builtin_bit_cast(unsigned,458 __builtin_shufflevector(459 from_vector8long_to_vector8char_var,460 from_vector8long_to_vector8char_var, 0, 1,461 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));462static_assert(__builtin_bit_cast(463 unsigned long long,464 __builtin_shufflevector(from_vector8long_to_vector8short_var,465 from_vector8long_to_vector8short_var,466 0, 1, 2, 3)) ==467 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));468constexpr vector8double from_vector8int_to_vector8double_var =469 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7},470 vector8double);471constexpr vector8float from_vector8int_to_vector8float_var =472 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7}, vector8float);473constexpr vector8long from_vector8int_to_vector8long_var =474 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7}, vector8long);475constexpr vector8int from_vector8int_to_vector8int_var =476 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7}, vector8int);477constexpr vector8short from_vector8int_to_vector8short_var =478 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7}, vector8short);479constexpr vector8char from_vector8int_to_vector8char_var =480 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7}, vector8char);481constexpr vector8BitInt8 from_vector8int_to_vector8BitInt8_var =482 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7},483 vector8BitInt8);484constexpr vector8BitInt32 from_vector8int_to_vector8BitInt32_var =485 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7},486 vector8BitInt32);487constexpr vector8BitInt128 from_vector8int_to_vector8BitInt128_var =488 __builtin_convertvector((vector8int){0, 1, 2, 3, 4, 5, 6, 7},489 vector8BitInt128);490static_assert(__builtin_bit_cast(unsigned,491 __builtin_shufflevector(492 from_vector8int_to_vector8char_var,493 from_vector8int_to_vector8char_var, 0, 1,494 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));495static_assert(__builtin_bit_cast(496 unsigned long long,497 __builtin_shufflevector(from_vector8int_to_vector8short_var,498 from_vector8int_to_vector8short_var,499 0, 1, 2, 3)) ==500 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));501constexpr vector8double from_vector8short_to_vector8double_var =502 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},503 vector8double);504constexpr vector8float from_vector8short_to_vector8float_var =505 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},506 vector8float);507constexpr vector8long from_vector8short_to_vector8long_var =508 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},509 vector8long);510constexpr vector8int from_vector8short_to_vector8int_var =511 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7}, vector8int);512constexpr vector8short from_vector8short_to_vector8short_var =513 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},514 vector8short);515constexpr vector8char from_vector8short_to_vector8char_var =516 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},517 vector8char);518constexpr vector8BitInt8 from_vector8short_to_vector8BitInt8_var =519 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},520 vector8BitInt8);521constexpr vector8BitInt32 from_vector8short_to_vector8BitInt32_var =522 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},523 vector8BitInt32);524constexpr vector8BitInt128 from_vector8short_to_vector8BitInt128_var =525 __builtin_convertvector((vector8short){0, 1, 2, 3, 4, 5, 6, 7},526 vector8BitInt128);527static_assert(__builtin_bit_cast(unsigned,528 __builtin_shufflevector(529 from_vector8short_to_vector8char_var,530 from_vector8short_to_vector8char_var, 0, 1,531 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));532static_assert(__builtin_bit_cast(533 unsigned long long,534 __builtin_shufflevector(from_vector8short_to_vector8short_var,535 from_vector8short_to_vector8short_var,536 0, 1, 2, 3)) ==537 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));538constexpr vector8double from_vector8char_to_vector8double_var =539 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},540 vector8double);541constexpr vector8float from_vector8char_to_vector8float_var =542 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},543 vector8float);544constexpr vector8long from_vector8char_to_vector8long_var =545 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7}, vector8long);546constexpr vector8int from_vector8char_to_vector8int_var =547 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7}, vector8int);548constexpr vector8short from_vector8char_to_vector8short_var =549 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},550 vector8short);551constexpr vector8char from_vector8char_to_vector8char_var =552 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7}, vector8char);553constexpr vector8BitInt8 from_vector8char_to_vector8BitInt8_var =554 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},555 vector8BitInt8);556constexpr vector8BitInt32 from_vector8char_to_vector8BitInt32_var =557 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},558 vector8BitInt32);559constexpr vector8BitInt128 from_vector8char_to_vector8BitInt128_var =560 __builtin_convertvector((vector8char){0, 1, 2, 3, 4, 5, 6, 7},561 vector8BitInt128);562static_assert(__builtin_bit_cast(unsigned,563 __builtin_shufflevector(564 from_vector8char_to_vector8char_var,565 from_vector8char_to_vector8char_var, 0, 1,566 2, 3)) == (LITTLE_END ? 0x03020100 : 0x00010203));567static_assert(__builtin_bit_cast(568 unsigned long long,569 __builtin_shufflevector(from_vector8char_to_vector8short_var,570 from_vector8char_to_vector8short_var,571 0, 1, 2, 3)) ==572 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));573constexpr vector8double from_vector8BitInt8_to_vector8double_var =574 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},575 vector8double);576constexpr vector8float from_vector8BitInt8_to_vector8float_var =577 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},578 vector8float);579constexpr vector8long from_vector8BitInt8_to_vector8long_var =580 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},581 vector8long);582constexpr vector8int from_vector8BitInt8_to_vector8int_var =583 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},584 vector8int);585constexpr vector8short from_vector8BitInt8_to_vector8short_var =586 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},587 vector8short);588constexpr vector8char from_vector8BitInt8_to_vector8char_var =589 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},590 vector8char);591constexpr vector8BitInt8 from_vector8BitInt8_to_vector8BitInt8_var =592 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},593 vector8BitInt8);594constexpr vector8BitInt32 from_vector8BitInt8_to_vector8BitInt32_var =595 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},596 vector8BitInt32);597constexpr vector8BitInt128 from_vector8BitInt8_to_vector8BitInt128_var =598 __builtin_convertvector((vector8BitInt8){0, 1, 2, 3, 4, 5, 6, 7},599 vector8BitInt128);600static_assert(__builtin_bit_cast(unsigned,601 __builtin_shufflevector(602 from_vector8BitInt8_to_vector8char_var,603 from_vector8BitInt8_to_vector8char_var, 0,604 1, 2, 3)) ==605 (LITTLE_END ? 0x03020100 : 0x00010203));606static_assert(__builtin_bit_cast(unsigned long long,607 __builtin_shufflevector(608 from_vector8BitInt8_to_vector8short_var,609 from_vector8BitInt8_to_vector8short_var, 0,610 1, 2, 3)) ==611 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));612constexpr vector8double from_vector8BitInt32_to_vector8double_var =613 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},614 vector8double);615constexpr vector8float from_vector8BitInt32_to_vector8float_var =616 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},617 vector8float);618constexpr vector8long from_vector8BitInt32_to_vector8long_var =619 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},620 vector8long);621constexpr vector8int from_vector8BitInt32_to_vector8int_var =622 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},623 vector8int);624constexpr vector8short from_vector8BitInt32_to_vector8short_var =625 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},626 vector8short);627constexpr vector8char from_vector8BitInt32_to_vector8char_var =628 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},629 vector8char);630constexpr vector8BitInt8 from_vector8BitInt32_to_vector8BitInt8_var =631 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},632 vector8BitInt8);633constexpr vector8BitInt32 from_vector8BitInt32_to_vector8BitInt32_var =634 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},635 vector8BitInt32);636constexpr vector8BitInt128 from_vector8BitInt32_to_vector8BitInt128_var =637 __builtin_convertvector((vector8BitInt32){0, 1, 2, 3, 4, 5, 6, 7},638 vector8BitInt128);639static_assert(__builtin_bit_cast(unsigned,640 __builtin_shufflevector(641 from_vector8BitInt32_to_vector8char_var,642 from_vector8BitInt32_to_vector8char_var, 0,643 1, 2, 3)) ==644 (LITTLE_END ? 0x03020100 : 0x00010203));645static_assert(__builtin_bit_cast(unsigned long long,646 __builtin_shufflevector(647 from_vector8BitInt32_to_vector8short_var,648 from_vector8BitInt32_to_vector8short_var,649 0, 1, 2, 3)) ==650 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));651constexpr vector8double from_vector8BitInt128_to_vector8double_var =652 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},653 vector8double);654constexpr vector8float from_vector8BitInt128_to_vector8float_var =655 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},656 vector8float);657constexpr vector8long from_vector8BitInt128_to_vector8long_var =658 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},659 vector8long);660constexpr vector8int from_vector8BitInt128_to_vector8int_var =661 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},662 vector8int);663constexpr vector8short from_vector8BitInt128_to_vector8short_var =664 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},665 vector8short);666constexpr vector8char from_vector8BitInt128_to_vector8char_var =667 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},668 vector8char);669constexpr vector8BitInt8 from_vector8BitInt128_to_vector8BitInt8_var =670 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},671 vector8BitInt8);672constexpr vector8BitInt32 from_vector8BitInt128_to_vector8BitInt32_var =673 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},674 vector8BitInt32);675constexpr vector8BitInt128 from_vector8BitInt128_to_vector8BitInt128_var =676 __builtin_convertvector((vector8BitInt128){0, 1, 2, 3, 4, 5, 6, 7},677 vector8BitInt128);678static_assert(__builtin_bit_cast(unsigned,679 __builtin_shufflevector(680 from_vector8BitInt128_to_vector8char_var,681 from_vector8BitInt128_to_vector8char_var,682 0, 1, 2, 3)) ==683 (LITTLE_END ? 0x03020100 : 0x00010203));684static_assert(__builtin_bit_cast(unsigned long long,685 __builtin_shufflevector(686 from_vector8BitInt128_to_vector8short_var,687 from_vector8BitInt128_to_vector8short_var,688 0, 1, 2, 3)) ==689 (LITTLE_END ? 0x0003000200010000 : 0x0000000100020003));690;691#undef CHECK_ALL_COMBINATIONS692#undef CHECK_TO_ALL_TYPES693#undef CHECK_NUM694 695// Shuffle vector696constexpr vector4char vector4charConst1 = {0, 1, 2, 3};697constexpr vector4char vector4charConst2 = {4, 5, 6, 7};698constexpr vector8char vector8intConst = {8, 9, 10, 11, 12, 13, 14, 15};699 700constexpr vector4char vectorShuffle1 =701 __builtin_shufflevector(vector4charConst1, vector4charConst2, 0, 1, 2, 3);702static_assert(__builtin_bit_cast(unsigned, vectorShuffle1) ==703 (LITTLE_END ? 0x03020100 : 0x00010203));704constexpr vector4char vectorShuffle2 =705 __builtin_shufflevector(vector4charConst1, vector4charConst2, 4, 5, 6, 7);706static_assert(__builtin_bit_cast(unsigned, vectorShuffle2) ==707 (LITTLE_END ? 0x07060504 : 0x04050607));708constexpr vector4char vectorShuffle3 =709 __builtin_shufflevector(vector4charConst1, vector4charConst2, 0, 2, 4, 6);710static_assert(__builtin_bit_cast(unsigned, vectorShuffle3) ==711 (LITTLE_END ? 0x06040200 : 0x00020406));712constexpr vector8char vectorShuffle4 = __builtin_shufflevector(713 vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);714static_assert(__builtin_bit_cast(unsigned long long, vectorShuffle4) ==715 (LITTLE_END ? 0x0E0C0A080E0C0A08 : 0x080A0C0E080A0C0E));716constexpr vector4char vectorShuffle5 =717 __builtin_shufflevector(vector8intConst, vector8intConst, 0, 2, 4, 6);718static_assert(__builtin_bit_cast(unsigned, vectorShuffle5) ==719 (LITTLE_END ? 0x0E0C0A08 : 0x080A0C0E));720constexpr vector8char vectorShuffle6 = __builtin_shufflevector(721 vector4charConst1, vector4charConst2, 0, 2, 4, 6, 1, 3, 5, 7);722static_assert(__builtin_bit_cast(unsigned long long, vectorShuffle6) ==723 (LITTLE_END ? 0x0705030106040200 : 0x0002040601030507));724 725constexpr vector4char726 vectorShuffleFail1 = // expected-error {{constexpr variable 'vectorShuffleFail1'\727 must be initialized by a constant expression}}728 __builtin_shufflevector( // expected-error {{index for __builtin_shufflevector \729not within the bounds of the input vectors; index of -1 found at position 0 is not \730permitted in a constexpr context}}731 vector4charConst1,732 vector4charConst2, -1, -1, -1, -1);733 734namespace UnaryShuffleUnsupported {735 typedef int vi6 __attribute__((ext_vector_type(2)));736 constexpr int foo() { // expected-error {{never produces a constant expression}}737 vi6 a = {1,2};738 vi6 b = {3,4};739 vi6 r = __builtin_shufflevector(a, b); // expected-note 2{{subexpression not valid in a constant expression}}740 741 return r[0] + r[1];742 }743 static_assert(foo() == 0); // expected-error {{not an integral constant expression}} \744 // expected-note {{in call to}}745}746 747static_assert(__builtin_reduce_add((vector4char){}) == 0);748static_assert(__builtin_reduce_add((vector4char){1, 2, 3, 4}) == 10);749static_assert(__builtin_reduce_add((vector4short){10, 20, 30, 40}) == 100);750static_assert(__builtin_reduce_add((vector4int){100, 200, 300, 400}) == 1000);751static_assert(__builtin_reduce_add((vector4long){1000, 2000, 3000, 4000}) == 10000);752constexpr int reduceAddInt1 = __builtin_reduce_add((vector4int){~(1 << 31), 0, 0, 1});753// expected-error@-1 {{must be initialized by a constant expression}} \754// expected-note@-1 {{outside the range of representable values of type 'int'}}755constexpr long long reduceAddLong1 = __builtin_reduce_add((vector4long){~(1LL << 63), 0, 0, 1});756// expected-error@-1 {{must be initialized by a constant expression}} \757// expected-note@-1 {{outside the range of representable values of type 'long long'}}758constexpr int reduceAddInt2 = __builtin_reduce_add((vector4int){(1 << 31), 0, 0, -1});759// expected-error@-1 {{must be initialized by a constant expression}} \760// expected-note@-1 {{outside the range of representable values of type 'int'}}761constexpr long long reduceAddLong2 = __builtin_reduce_add((vector4long){(1LL << 63), 0, 0, -1});762// expected-error@-1 {{must be initialized by a constant expression}} \763// expected-note@-1 {{outside the range of representable values of type 'long long'}}764static_assert(__builtin_reduce_add((vector4uint){~0U, 0, 0, 1}) == 0);765static_assert(__builtin_reduce_add((vector4ulong){~0ULL, 0, 0, 1}) == 0);766 767static_assert(__builtin_reduce_mul((vector4char){}) == 0);768static_assert(__builtin_reduce_mul((vector4char){1, 2, 3, 4}) == 24);769static_assert(__builtin_reduce_mul((vector4short){1, 2, 30, 40}) == 2400);770static_assert(__builtin_reduce_mul((vector4int){10, 20, 300, 400}) == 24000000);771static_assert(__builtin_reduce_mul((vector4long){1000L, 2000L, 3000L, 4000L}) == 24000000000000L);772constexpr int reduceMulInt1 = __builtin_reduce_mul((vector4int){~(1 << 31), 1, 1, 2});773// expected-error@-1 {{must be initialized by a constant expression}} \774// expected-note@-1 {{outside the range of representable values of type 'int'}}775constexpr long long reduceMulLong1 = __builtin_reduce_mul((vector4long){~(1LL << 63), 1, 1, 2});776// expected-error@-1 {{must be initialized by a constant expression}} \777// expected-note@-1 {{outside the range of representable values of type 'long long'}}778constexpr int reduceMulInt2 = __builtin_reduce_mul((vector4int){(1 << 31), 1, 1, 2});779// expected-error@-1 {{must be initialized by a constant expression}} \780// expected-note@-1 {{outside the range of representable values of type 'int'}}781constexpr long long reduceMulLong2 = __builtin_reduce_mul((vector4long){(1LL << 63), 1, 1, 2});782// expected-error@-1 {{must be initialized by a constant expression}} \783// expected-note@-1 {{outside the range of representable values of type 'long long'}}784static_assert(__builtin_reduce_mul((vector4uint){~0U, 1, 1, 2}) == ~0U - 1);785static_assert(__builtin_reduce_mul((vector4ulong){~0ULL, 1, 1, 2}) == ~0ULL - 1);786 787static_assert(__builtin_reduce_and((vector4char){}) == 0);788static_assert(__builtin_reduce_and((vector4char){(char)0x11, (char)0x22, (char)0x44, (char)0x88}) == 0);789static_assert(__builtin_reduce_and((vector4short){(short)0x1111, (short)0x2222, (short)0x4444, (short)0x8888}) == 0);790static_assert(__builtin_reduce_and((vector4int){(int)0x11111111, (int)0x22222222, (int)0x44444444, (int)0x88888888}) == 0);791static_assert(__builtin_reduce_and((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0x8888888888888888L}) == 0L);792static_assert(__builtin_reduce_and((vector4char){(char)-1, (char)~0x22, (char)~0x44, (char)~0x88}) == 0x11);793static_assert(__builtin_reduce_and((vector4short){(short)~0x1111, (short)-1, (short)~0x4444, (short)~0x8888}) == 0x2222);794static_assert(__builtin_reduce_and((vector4int){(int)~0x11111111, (int)~0x22222222, (int)-1, (int)~0x88888888}) == 0x44444444);795static_assert(__builtin_reduce_and((vector4long){(long long)~0x1111111111111111L, (long long)~0x2222222222222222L, (long long)~0x4444444444444444L, (long long)-1}) == 0x8888888888888888L);796static_assert(__builtin_reduce_and((vector4uint){0x11111111U, 0x22222222U, 0x44444444U, 0x88888888U}) == 0U);797static_assert(__builtin_reduce_and((vector4ulong){0x1111111111111111UL, 0x2222222222222222UL, 0x4444444444444444UL, 0x8888888888888888UL}) == 0L);798 799static_assert(__builtin_reduce_or((vector4char){}) == 0);800static_assert(__builtin_reduce_or((vector4char){(char)0x11, (char)0x22, (char)0x44, (char)0x88}) == (char)0xFF);801static_assert(__builtin_reduce_or((vector4short){(short)0x1111, (short)0x2222, (short)0x4444, (short)0x8888}) == (short)0xFFFF);802static_assert(__builtin_reduce_or((vector4int){(int)0x11111111, (int)0x22222222, (int)0x44444444, (int)0x88888888}) == (int)0xFFFFFFFF);803static_assert(__builtin_reduce_or((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0x8888888888888888L}) == (long long)0xFFFFFFFFFFFFFFFFL);804static_assert(__builtin_reduce_or((vector4char){(char)0, (char)0x22, (char)0x44, (char)0x88}) == ~0x11);805static_assert(__builtin_reduce_or((vector4short){(short)0x1111, (short)0, (short)0x4444, (short)0x8888}) == ~0x2222);806static_assert(__builtin_reduce_or((vector4int){(int)0x11111111, (int)0x22222222, (int)0, (int)0x88888888}) == ~0x44444444);807static_assert(__builtin_reduce_or((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0}) == ~0x8888888888888888L);808static_assert(__builtin_reduce_or((vector4uint){0x11111111U, 0x22222222U, 0x44444444U, 0x88888888U}) == 0xFFFFFFFFU);809static_assert(__builtin_reduce_or((vector4ulong){0x1111111111111111UL, 0x2222222222222222UL, 0x4444444444444444UL, 0x8888888888888888UL}) == 0xFFFFFFFFFFFFFFFFL);810 811static_assert(__builtin_reduce_xor((vector4char){}) == 0);812static_assert(__builtin_reduce_xor((vector4char){(char)0x11, (char)0x22, (char)0x44, (char)0x88}) == (char)0xFF);813static_assert(__builtin_reduce_xor((vector4short){(short)0x1111, (short)0x2222, (short)0x4444, (short)0x8888}) == (short)0xFFFF);814static_assert(__builtin_reduce_xor((vector4int){(int)0x11111111, (int)0x22222222, (int)0x44444444, (int)0x88888888}) == (int)0xFFFFFFFF);815static_assert(__builtin_reduce_xor((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0x8888888888888888L}) == (long long)0xFFFFFFFFFFFFFFFFL);816static_assert(__builtin_reduce_xor((vector4uint){0x11111111U, 0x22222222U, 0x44444444U, 0x88888888U}) == 0xFFFFFFFFU);817static_assert(__builtin_reduce_xor((vector4ulong){0x1111111111111111UL, 0x2222222222222222UL, 0x4444444444444444UL, 0x8888888888888888UL}) == 0xFFFFFFFFFFFFFFFFUL);818 819static_assert(__builtin_reduce_min((vector4char){}) == 0);820static_assert(__builtin_reduce_min((vector4char){(char)0x11, (char)0x22, (char)0x44, (char)0x88}) == (char)0x88);821static_assert(__builtin_reduce_min((vector4short){(short)0x1111, (short)0x2222, (short)0x4444, (short)0x8888}) == (short)0x8888);822static_assert(__builtin_reduce_min((vector4int){(int)0x11111111, (int)0x22222222, (int)0x44444444, (int)0x88888888}) == (int)0x88888888);823static_assert(__builtin_reduce_min((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0x8888888888888888L}) == (long long)0x8888888888888888L);824static_assert(__builtin_reduce_min((vector4uint){0x11111111U, 0x22222222U, 0x44444444U, 0x88888888U}) == 0x11111111U);825static_assert(__builtin_reduce_min((vector4ulong){0x1111111111111111UL, 0x2222222222222222UL, 0x4444444444444444UL, 0x8888888888888888UL}) == 0x1111111111111111UL);826static_assert(__builtin_reduce_max((vector4char){}) == 0);827static_assert(__builtin_reduce_max((vector4char){(char)0x11, (char)0x22, (char)0x44, (char)0x88}) == (char)0x44);828static_assert(__builtin_reduce_max((vector4short){(short)0x1111, (short)0x2222, (short)0x4444, (short)0x8888}) == (short)0x4444);829static_assert(__builtin_reduce_max((vector4int){(int)0x11111111, (int)0x22222222, (int)0x44444444, (int)0x88888888}) == (int)0x44444444);830static_assert(__builtin_reduce_max((vector4long){(long long)0x1111111111111111L, (long long)0x2222222222222222L, (long long)0x4444444444444444L, (long long)0x8888888888888888L}) == (long long)0x4444444444444444L);831static_assert(__builtin_reduce_max((vector4uint){0x11111111U, 0x22222222U, 0x44444444U, 0x88888888U}) == 0x88888888U);832static_assert(__builtin_reduce_max((vector4ulong){0x1111111111111111UL, 0x2222222222222222UL, 0x4444444444444444UL, 0x8888888888888888UL}) == 0x8888888888888888UL);833 834static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_popcount((vector4char){1, 2, 3, 4})) == (LITTLE_END ? 0x01020101 : 0x01010201));835static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_popcount((vector4short){0, 0x0F0F, ~0, ~0x0F0F})) == (LITTLE_END ? 0x0008001000080000 : 0x0000000800100008));836static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4int){1, 2, 3, 4})) == 5);837static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4int){0, 0xF0F0, ~0, ~0xF0F0})) == 16 * sizeof(int));838static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4long){1L, 2L, 3L, 4L})) == 5L);839static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4long){0L, 0xF0F0L, ~0L, ~0xF0F0L})) == 16 * sizeof(long long));840static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4uint){1U, 2U, 3U, 4U})) == 5U);841static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4uint){0U, 0xF0F0U, ~0U, ~0xF0F0U})) == 16 * sizeof(int));842static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4ulong){1UL, 2UL, 3UL, 4UL})) == 5UL);843static_assert(__builtin_reduce_add(__builtin_elementwise_popcount((vector4ulong){0ULL, 0xF0F0ULL, ~0ULL, ~0xF0F0ULL})) == 16 * sizeof(unsigned long long));844static_assert(__builtin_elementwise_popcount(0) == 0);845static_assert(__builtin_elementwise_popcount(0xF0F0) == 8);846static_assert(__builtin_elementwise_popcount(~0) == 8 * sizeof(int));847static_assert(__builtin_elementwise_popcount(0U) == 0);848static_assert(__builtin_elementwise_popcount(0xF0F0U) == 8);849static_assert(__builtin_elementwise_popcount(~0U) == 8 * sizeof(int));850static_assert(__builtin_elementwise_popcount(0L) == 0);851static_assert(__builtin_elementwise_popcount(0xF0F0L) == 8);852static_assert(__builtin_elementwise_popcount(~0LL) == 8 * sizeof(long long));853 854static_assert(__builtin_elementwise_bitreverse(0x12345678) == 0x1E6A2C48);855static_assert(__builtin_elementwise_bitreverse(0x0123456789ABCDEFULL) == 0xF7B3D591E6A2C480);856static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_bitreverse((vector4char){1, 2, 4, 8})) == (LITTLE_END ? 0x10204080 : 0x80402010));857static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_bitreverse((vector4short){1, 2, 4, 8})) == (LITTLE_END ? 0x1000200040008000 : 0x8000400020001000));858 859static_assert(__builtin_elementwise_add_sat(1, 2) == 3);860static_assert(__builtin_elementwise_add_sat(1U, 2U) == 3U);861static_assert(__builtin_elementwise_add_sat(~(1 << 31), 42) == ~(1 << 31));862static_assert(__builtin_elementwise_add_sat((1 << 31), -42) == (1 << 31));863static_assert(__builtin_elementwise_add_sat(~0U, 1U) == ~0U);864static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_add_sat((vector4char){1, 2, 3, 4}, (vector4char){1, 2, 3, 4})) == (LITTLE_END ? 0x08060402 : 0x02040608));865static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_add_sat((vector4uchar){1, 2, 3, 4}, (vector4uchar){0, 1, 2, 3})) == (LITTLE_END ? 0x07050301U : 0x01030507U));866static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_add_sat((vector4short){(short)0x8000, (short)0x8001, (short)0x8002, (short)0x8003}, (vector4short){-7, -8, -9, -10}) == (LITTLE_END ? 0x8000800080008000 : 0x8000800080008000)));867 868static_assert(__builtin_elementwise_sub_sat(1, 2) == -1);869static_assert(__builtin_elementwise_sub_sat(2U, 1U) == 1U);870static_assert(__builtin_elementwise_sub_sat(~(1 << 31), -42) == ~(1 << 31));871static_assert(__builtin_elementwise_sub_sat((1 << 31), 42) == (1 << 31));872static_assert(__builtin_elementwise_sub_sat(0U, 1U) == 0U);873static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_sub_sat((vector4char){5, 4, 3, 2}, (vector4char){1, 1, 1, 1})) == (LITTLE_END ? 0x01020304 : 0x04030201));874static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_sub_sat((vector4uchar){5, 4, 3, 2}, (vector4uchar){1, 1, 1, 1})) == (LITTLE_END ? 0x01020304U : 0x04030201U));875static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_sub_sat((vector4short){(short)0x8000, (short)0x8001, (short)0x8002, (short)0x8003}, (vector4short){7, 8, 9, 10}) == (LITTLE_END ? 0x8000800080008000 : 0x8000800080008000)));876 877static_assert(__builtin_elementwise_max(1, 2) == 2);878static_assert(__builtin_elementwise_max(-1, 1) == 1);879static_assert(__builtin_elementwise_max(1U, 2U) == 2U);880static_assert(__builtin_elementwise_max(~0U, 0U) == ~0U);881static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_max((vector4char){1, -2, 3, -4}, (vector4char){4, -3, 2, -1})) == (LITTLE_END ? 0xFF03FE04 : 0x04FE03FF ));882static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_max((vector4uchar){1, 2, 3, 4}, (vector4uchar){4, 3, 2, 1})) == 0x04030304U);883static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_max((vector4short){1, -2, 3, -4}, (vector4short){4, -3, 2, -1})) == (LITTLE_END ? 0xFFFF0003FFFE0004 : 0x0004FFFE0003FFFF));884 885static_assert(__builtin_elementwise_min(1, 2) == 1);886static_assert(__builtin_elementwise_min(-1, 1) == -1);887static_assert(__builtin_elementwise_min(1U, 2U) == 1U);888static_assert(__builtin_elementwise_min(~0U, 0U) == 0U);889static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_min((vector4char){1, -2, 3, -4}, (vector4char){4, -3, 2, -1})) == (LITTLE_END ? 0xFC02FD01 : 0x01FD02FC));890static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_min((vector4uchar){1, 2, 3, 4}, (vector4uchar){4, 3, 2, 1})) == 0x01020201U);891static_assert(__builtin_bit_cast(unsigned long long, __builtin_elementwise_min((vector4short){1, -2, 3, -4}, (vector4short){4, -3, 2, -1})) == (LITTLE_END ? 0xFFFC0002FFFD0001 : 0x0001FFFD0002FFFC));892 893static_assert(__builtin_elementwise_abs(10) == 10);894static_assert(__builtin_elementwise_abs(-10) == 10);895static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_abs((vector4char){-1, -2, -3, 4})) == (LITTLE_END ? 0x04030201 : 0x01020304));896static_assert(__builtin_elementwise_abs((int)(-2147483648)) == (int)(-2147483648)); // the absolute value of the most negative integer remains the most negative integer897 898// check floating point for elementwise abs899#define CHECK_FOUR_FLOAT_VEC(vec1, vec2) \900 static_assert(__builtin_fabs(vec1[0] - vec2[0]) < 1e-6); \901 static_assert(__builtin_fabs(vec1[1] - vec2[1]) < 1e-6); \902 static_assert(__builtin_fabs(vec1[2] - vec2[2]) < 1e-6); \903 static_assert(__builtin_fabs(vec1[3] - vec2[3]) < 1e-6);904 905// checking floating point vector906CHECK_FOUR_FLOAT_VEC(__builtin_elementwise_abs((vector4float){-1.123, 2.123, -3.123, 4.123}), ((vector4float){1.123, 2.123, 3.123, 4.123}))907CHECK_FOUR_FLOAT_VEC(__builtin_elementwise_abs((vector4double){-1.123, 2.123, -3.123, 4.123}), ((vector4double){1.123, 2.123, 3.123, 4.123}))908static_assert(__builtin_elementwise_abs((float)-1.123) - (float)1.123 < 1e-6); // making sure one element works909#undef CHECK_FOUR_FLOAT_VEC910 911static_assert(__builtin_elementwise_clzg(2) == 30);912static_assert(__builtin_elementwise_clzg(2, 8) == 30);913static_assert(__builtin_elementwise_clzg(0, 8) == 8);914static_assert(__builtin_elementwise_clzg(0, 0) == 0);915static_assert(__builtin_elementwise_clzg((char)2) == 6);916static_assert(__builtin_elementwise_clzg((short)2) == 14);917static_assert(__builtin_elementwise_clzg((char)1) == 0x7);918static_assert(__builtin_elementwise_clzg((char)4) == 0x5);919static_assert(__builtin_elementwise_clzg((char)127) == 0x1);920static_assert(__builtin_elementwise_clzg((char)128) == 0x0);921static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_clzg((vector4char){1, 4, 127, (char)128})) == (LITTLE_END ? 0x00010507 : 0x07050100));922 923constexpr int clz0 = __builtin_elementwise_clzg(0);924// expected-error@-1 {{must be initialized by a constant expression}} \925// expected-note@-1 {{evaluation of __builtin_elementwise_clzg with a zero value is undefined}}926constexpr vector4char clz1 = __builtin_elementwise_clzg((vector4char){1, 0, 3, 4});927// expected-error@-1 {{must be initialized by a constant expression}} \928// expected-note@-1 {{evaluation of __builtin_elementwise_clzg with a zero value is undefined}}929static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_clzg((vector4char){1, 0, 127, 0}, (vector4char){9, -1, 9, -2})) == (LITTLE_END ? 0xFE01FF07 : 0x07FF01FE));930static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_clzg((vector4char){0, 0, 0, 0}, (vector4char){0, 0, 0, 0})) == 0);931 932static_assert(__builtin_elementwise_ctzg(2) == 1);933static_assert(__builtin_elementwise_ctzg(2, 8) == 1);934static_assert(__builtin_elementwise_ctzg(0, 8) == 8);935static_assert(__builtin_elementwise_ctzg(0, 0) == 0);936static_assert(__builtin_elementwise_ctzg((char)2) == 1);937static_assert(__builtin_elementwise_ctzg((short)2) == 1);938static_assert(__builtin_elementwise_ctzg((char)8) == 0x3);939static_assert(__builtin_elementwise_ctzg((char)32) == 0x5);940static_assert(__builtin_elementwise_ctzg((char)127) == 0x0);941static_assert(__builtin_elementwise_ctzg((char)128) == 0x7);942static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_ctzg((vector4char){8, 32, 127, (char)128})) == (LITTLE_END ? 0x07000503 : 0x03050007));943 944constexpr int ctz0 = __builtin_elementwise_ctzg(0);945// expected-error@-1 {{must be initialized by a constant expression}} \946// expected-note@-1 {{evaluation of __builtin_elementwise_ctzg with a zero value is undefined}}947constexpr vector4char ctz1 = __builtin_elementwise_ctzg((vector4char){1, 0, 3, 4});948// expected-error@-1 {{must be initialized by a constant expression}} \949// expected-note@-1 {{evaluation of __builtin_elementwise_ctzg with a zero value is undefined}}950static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_ctzg((vector4char){8, 0, 127, 0}, (vector4char){9, -1, 9, -2})) == (LITTLE_END ? 0xFE00FF03 : 0x03FF00FE));951static_assert(__builtin_bit_cast(unsigned, __builtin_elementwise_ctzg((vector4char){0, 0, 0, 0}, (vector4char){0, 0, 0, 0})) == 0);952 953// Non-vector floating point types.954static_assert(__builtin_elementwise_fma(2.0, 3.0, 4.0) == 10.0);955static_assert(__builtin_elementwise_fma(200.0, 300.0, 400.0) == 60400.0);956// Vector type.957constexpr vector4float fmaFloat1 =958 __builtin_elementwise_fma((vector4float){1.0, 2.0, 3.0, 4.0},959 (vector4float){2.0, 3.0, 4.0, 5.0},960 (vector4float){3.0, 4.0, 5.0, 6.0});961static_assert(fmaFloat1[0] == 5.0);962static_assert(fmaFloat1[1] == 10.0);963static_assert(fmaFloat1[2] == 17.0);964static_assert(fmaFloat1[3] == 26.0);965constexpr vector4double fmaDouble1 =966 __builtin_elementwise_fma((vector4double){1.0, 2.0, 3.0, 4.0},967 (vector4double){2.0, 3.0, 4.0, 5.0},968 (vector4double){3.0, 4.0, 5.0, 6.0});969static_assert(fmaDouble1[0] == 5.0);970static_assert(fmaDouble1[1] == 10.0);971static_assert(fmaDouble1[2] == 17.0);972static_assert(fmaDouble1[3] == 26.0);973 974constexpr float fmaArray[] = {2.0f, 2.0f, 2.0f, 2.0f};975constexpr float fmaResult = __builtin_elementwise_fma(fmaArray[1], fmaArray[2], fmaArray[3]);976static_assert(fmaResult == 6.0f, "");977 978static_assert(__builtin_elementwise_fshl((unsigned char)255, (unsigned char)0, (unsigned char)8) == (unsigned char)255);979static_assert(__builtin_elementwise_fshl((char)127, (char)0, (char)8) == (char)127);980static_assert(__builtin_elementwise_fshl((unsigned char)0, (unsigned char)255, (unsigned char)8) == (unsigned char)0);981static_assert(__builtin_elementwise_fshl((char)0, (char)127, (char)8) == (char)0);982static_assert(__builtin_elementwise_fshr((unsigned char)255, (unsigned char)0, (unsigned char)8) == (unsigned char)0);983static_assert(__builtin_elementwise_fshr((char)127, (char)0, (char)8) == (char)0);984static_assert(__builtin_elementwise_fshr((unsigned char)0, (unsigned char)255, (unsigned char)8) == (unsigned char)255);985static_assert(__builtin_elementwise_fshr((char)0, (char)127, (char)8) == (char)127);986static_assert(__builtin_elementwise_fshl((unsigned int)4294967295, (unsigned int)0, (unsigned int)32) == (unsigned int)4294967295);987static_assert(__builtin_elementwise_fshl((int)2147483647, (int)0, (int)32) == (int)2147483647);988static_assert(__builtin_elementwise_fshl((unsigned int)0, (unsigned int)4294967295, (unsigned int)32) == (unsigned int)0);989static_assert(__builtin_elementwise_fshl((int)0, (int)2147483647, (int)32) == (int)0);990static_assert(__builtin_elementwise_fshr((unsigned int)4294967295, (unsigned int)0, (unsigned int)32) == (unsigned int)0);991static_assert(__builtin_elementwise_fshr((int)2147483647, (int)0, (int)32) == (int)0);992static_assert(__builtin_elementwise_fshr((unsigned int)0, (unsigned int)4294967295, (unsigned int)32) == (unsigned int)4294967295);993static_assert(__builtin_elementwise_fshr((int)0, (int)2147483647, (int)32) == (int)2147483647);994static_assert(__builtin_elementwise_fshl((unsigned long long)18446744073709551615ULL, (unsigned long long)0, (unsigned long long)64) == (unsigned long long)18446744073709551615ULL);995static_assert(__builtin_elementwise_fshl((long long)9223372036854775807, (long long)0, (long long)64) == (long long)9223372036854775807);996static_assert(__builtin_elementwise_fshl((unsigned long long)0, (unsigned long long)18446744073709551615ULL, (unsigned long long)64) == (unsigned long long)0);997static_assert(__builtin_elementwise_fshl((long long)0, (long long)9223372036854775807, (long long)64) == (long long)0);998static_assert(__builtin_elementwise_fshr((unsigned long long)18446744073709551615ULL, (unsigned long long)0, (unsigned long long)64) == (unsigned long long)0);999static_assert(__builtin_elementwise_fshr((long long)9223372036854775807, (long long)0, (long long)64) == (long long)0);1000static_assert(__builtin_elementwise_fshr((unsigned long long)0, (unsigned long long)18446744073709551615ULL, (unsigned long long)64) == (unsigned long long)18446744073709551615ULL);1001static_assert(__builtin_elementwise_fshr((long long)0, (long long)9223372036854775807, (long long)64) == (long long)9223372036854775807);1002static_assert(__builtin_elementwise_fshl((short) 1, (short) 2, (short) 3) == (short)8);1003static_assert(__builtin_elementwise_fshl((short) 2, (short) 1, (short) 3) == (short)16);1004static_assert(__builtin_elementwise_fshl(1, 2 , 2) == 4);1005static_assert(__builtin_elementwise_fshl(2L, 1L , 2L) == 8L);1006static_assert(__builtin_elementwise_fshr((unsigned char)1, (unsigned char)2, (unsigned char)3) == (unsigned char)32);1007constexpr vector4uchar v4s_fshl_var =1008 __builtin_elementwise_fshl((vector4uchar){255, 15, 0, 2},1009 (vector4uchar){0, 15, 255, 1},1010 (vector4uchar){15, 11, 8, 3});1011static_assert(v4s_fshl_var[0] == 128);1012static_assert(v4s_fshl_var[1] == 120);1013static_assert(v4s_fshl_var[2] == 0);1014static_assert(v4s_fshl_var[3] == 16);1015constexpr vector4uchar v4s_fshr_var =1016 __builtin_elementwise_fshr((vector4uchar){255, 15, 0, 1},1017 (vector4uchar){0, 15, 255, 2},1018 (vector4uchar){15, 11, 8, 3});1019static_assert(v4s_fshr_var[0] == 254);1020static_assert(v4s_fshr_var[1] == 225);1021static_assert(v4s_fshr_var[2] == 255);1022static_assert(v4s_fshr_var[3] == 32);1023static_assert(__builtin_elementwise_fshl(v4s_fshl_var[0], v4s_fshl_var[1], v4s_fshl_var[2]) == 128);1024static_assert(__builtin_elementwise_fshr(v4s_fshr_var[0], v4s_fshr_var[1], v4s_fshr_var[2]) == 253);1025