================ @@ -10,11 +10,229 @@ using FourI128VecSize __attribute__((vector_size(64))) = __int128; using FourCharsExtVec __attribute__((ext_vector_type(4))) = char; using FourIntsExtVec __attribute__((ext_vector_type(4))) = int; +using FourLongLongsExtVec __attribute__((ext_vector_type(4))) = long long; +using FourFloatsExtVec __attribute__((ext_vector_type(4))) = float; +using FourDoublesExtVec __attribute__((ext_vector_type(4))) = double; using FourI128ExtVec __attribute__((ext_vector_type(4))) = __int128; + +// Next a series of tests to make sure these operations are usable in +// constexpr functions. Template instantiations don't emit Winvalid-constexpr, +// so we have to do these as macros. +#define MathShiftOps(Type) \ + constexpr auto MathShiftOps##Type(Type a, Type b) { \ + a = a + b; \ + a = a - b; \ + a = a * b; \ + a = a / b; \ + b = a + 1; \ + b = a - 1; \ + b = a * 1; \ + b = a / 1; \ + a += a; \ + a -= a; \ + a *= a; \ + a /= a; \ + b += a; \ + b -= a; \ + b *= a; \ + b /= a; \ + b = (a += a); \ + b = (a -= a); \ + b = (a *= a); \ + b = (a /= a); \ + b = (b += a); \ + b = (b -= a); \ + b = (b *= a); \ + b = (b /= a); \ + a < b; \ + a > b; \ + a <= b; \ + a >= b; \ + a == b; \ + a != b; \ + a &&b; \ + a || b; \ + auto c = (a, b); \ + return c; \ + } + +// Ops specific to Integers. +#define MathShiftOpsInts(Type) \ + constexpr auto MathShiftopsInts##Type(Type a, Type b) { \ + a = a << b; \ + a = a >> b; \ + a = a << 3; \ + a = a >> 3; \ + a = 3 << b; \ + a = 3 >> b; \ + a <<= b; \ + a >>= b; \ + a <<= 3; \ + a >>= 3; \ + b = (a <<= b); \ + b = (a >>= b); \ + b = (a <<= 3); \ + b = (a >>= 3); \ + a = a % b; \ + a &b; \ + a | b; \ + a ^ b; \ + return a; \ + } + +MathShiftOps(FourCharsVecSize); +MathShiftOps(FourIntsVecSize); +MathShiftOps(FourLongLongsVecSize); +MathShiftOps(FourFloatsVecSize); +MathShiftOps(FourDoublesVecSize); +MathShiftOps(FourCharsExtVec); +MathShiftOps(FourIntsExtVec); +MathShiftOps(FourLongLongsExtVec); +MathShiftOps(FourFloatsExtVec); +MathShiftOps(FourDoublesExtVec); + +MathShiftOpsInts(FourCharsVecSize); +MathShiftOpsInts(FourIntsVecSize); +MathShiftOpsInts(FourLongLongsVecSize); +MathShiftOpsInts(FourCharsExtVec); +MathShiftOpsInts(FourIntsExtVec); +MathShiftOpsInts(FourLongLongsExtVec); ---------------- yronglin wrote:
Sure, added more int128 tests, it's works well in my local. https://github.com/llvm/llvm-project/pull/108949 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits