From b9874ef72e102a3a66c080dc457606c5d5335c6d Mon Sep 17 00:00:00 2001 From: Matthias Kretz Date: Fri, 27 Sep 2024 12:08:00 +0200 Subject: [PATCH] Older clang needs constexpr instead of consteval ChangeLog: * vir/simd_permute.h: Use VIR_CONSTEVAL placeholder to declare permutation functions as consteval/constexpr. --- vir/simd_permute.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/vir/simd_permute.h b/vir/simd_permute.h index c1d6f3d..9c2fc5e 100644 --- a/vir/simd_permute.h +++ b/vir/simd_permute.h @@ -42,11 +42,17 @@ namespace vir constexpr int simd_permute_uninit = simd_permute_zero - 1; +#if defined __clang__ and __clang__ <= 13 +#define VIR_CONSTEVAL constexpr +#else +#define VIR_CONSTEVAL consteval +#endif + namespace simd_permutations { struct DuplicateEven { - consteval unsigned + VIR_CONSTEVAL unsigned operator()(unsigned i) const { return i & ~1u; } }; @@ -55,7 +61,7 @@ namespace vir struct DuplicateOdd { - consteval unsigned + VIR_CONSTEVAL unsigned operator()(unsigned i) const { return i | 1u; } }; @@ -65,7 +71,7 @@ namespace vir template struct SwapNeighbors { - consteval unsigned + VIR_CONSTEVAL unsigned operator()(unsigned i, auto size) const { static_assert(size % (2 * N) == 0, @@ -85,7 +91,7 @@ namespace vir template struct Broadcast { - consteval int + VIR_CONSTEVAL int operator()(int) const { return Position; } }; @@ -99,7 +105,7 @@ namespace vir struct Reverse { - consteval int + VIR_CONSTEVAL int operator()(int i) const { return -1 - i; } }; @@ -112,7 +118,7 @@ namespace vir static constexpr int Offset = O; static constexpr bool is_even_rotation = Offset % 2 == 0; - consteval int + VIR_CONSTEVAL int operator()(int i, auto size) const { return (i + Offset) % size.value; } }; @@ -123,7 +129,7 @@ namespace vir template struct Shift { - consteval int + VIR_CONSTEVAL int operator()(int i, int size) const { const int j = i + Offset; @@ -138,6 +144,8 @@ namespace vir inline constexpr Shift shift {}; } +#undef VIR_CONSTEVAL + template F> VIR_ALWAYS_INLINE constexpr stdx::resize_simd_t