Skip to content

Commit b9874ef

Browse files
committed
Older clang needs constexpr instead of consteval
ChangeLog: * vir/simd_permute.h: Use VIR_CONSTEVAL placeholder to declare permutation functions as consteval/constexpr.
1 parent 2c86135 commit b9874ef

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

vir/simd_permute.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@ namespace vir
4242

4343
constexpr int simd_permute_uninit = simd_permute_zero - 1;
4444

45+
#if defined __clang__ and __clang__ <= 13
46+
#define VIR_CONSTEVAL constexpr
47+
#else
48+
#define VIR_CONSTEVAL consteval
49+
#endif
50+
4551
namespace simd_permutations
4652
{
4753
struct DuplicateEven
4854
{
49-
consteval unsigned
55+
VIR_CONSTEVAL unsigned
5056
operator()(unsigned i) const
5157
{ return i & ~1u; }
5258
};
@@ -55,7 +61,7 @@ namespace vir
5561

5662
struct DuplicateOdd
5763
{
58-
consteval unsigned
64+
VIR_CONSTEVAL unsigned
5965
operator()(unsigned i) const
6066
{ return i | 1u; }
6167
};
@@ -65,7 +71,7 @@ namespace vir
6571
template <unsigned N>
6672
struct SwapNeighbors
6773
{
68-
consteval unsigned
74+
VIR_CONSTEVAL unsigned
6975
operator()(unsigned i, auto size) const
7076
{
7177
static_assert(size % (2 * N) == 0,
@@ -85,7 +91,7 @@ namespace vir
8591
template <int Position>
8692
struct Broadcast
8793
{
88-
consteval int
94+
VIR_CONSTEVAL int
8995
operator()(int) const
9096
{ return Position; }
9197
};
@@ -99,7 +105,7 @@ namespace vir
99105

100106
struct Reverse
101107
{
102-
consteval int
108+
VIR_CONSTEVAL int
103109
operator()(int i) const
104110
{ return -1 - i; }
105111
};
@@ -112,7 +118,7 @@ namespace vir
112118
static constexpr int Offset = O;
113119
static constexpr bool is_even_rotation = Offset % 2 == 0;
114120

115-
consteval int
121+
VIR_CONSTEVAL int
116122
operator()(int i, auto size) const
117123
{ return (i + Offset) % size.value; }
118124
};
@@ -123,7 +129,7 @@ namespace vir
123129
template <int Offset>
124130
struct Shift
125131
{
126-
consteval int
132+
VIR_CONSTEVAL int
127133
operator()(int i, int size) const
128134
{
129135
const int j = i + Offset;
@@ -138,6 +144,8 @@ namespace vir
138144
inline constexpr Shift<Offset> shift {};
139145
}
140146

147+
#undef VIR_CONSTEVAL
148+
141149
template <std::size_t N = 0, vir::any_simd_or_mask V,
142150
detail::index_permutation_function<V::size()> F>
143151
VIR_ALWAYS_INLINE constexpr stdx::resize_simd_t<N == 0 ? V::size() : N, V>

0 commit comments

Comments
 (0)