Skip to content

Commit

Permalink
Older clang needs constexpr instead of consteval
Browse files Browse the repository at this point in the history
ChangeLog:

	* vir/simd_permute.h: Use VIR_CONSTEVAL placeholder to declare
	permutation functions as consteval/constexpr.
  • Loading branch information
mattkretz committed Sep 27, 2024
1 parent 2c86135 commit b9874ef
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions vir/simd_permute.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
};
Expand All @@ -55,7 +61,7 @@ namespace vir

struct DuplicateOdd
{
consteval unsigned
VIR_CONSTEVAL unsigned
operator()(unsigned i) const
{ return i | 1u; }
};
Expand All @@ -65,7 +71,7 @@ namespace vir
template <unsigned N>
struct SwapNeighbors
{
consteval unsigned
VIR_CONSTEVAL unsigned
operator()(unsigned i, auto size) const
{
static_assert(size % (2 * N) == 0,
Expand All @@ -85,7 +91,7 @@ namespace vir
template <int Position>
struct Broadcast
{
consteval int
VIR_CONSTEVAL int
operator()(int) const
{ return Position; }
};
Expand All @@ -99,7 +105,7 @@ namespace vir

struct Reverse
{
consteval int
VIR_CONSTEVAL int
operator()(int i) const
{ return -1 - i; }
};
Expand All @@ -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; }
};
Expand All @@ -123,7 +129,7 @@ namespace vir
template <int Offset>
struct Shift
{
consteval int
VIR_CONSTEVAL int
operator()(int i, int size) const
{
const int j = i + Offset;
Expand All @@ -138,6 +144,8 @@ namespace vir
inline constexpr Shift<Offset> shift {};
}

#undef VIR_CONSTEVAL

template <std::size_t N = 0, vir::any_simd_or_mask V,
detail::index_permutation_function<V::size()> F>
VIR_ALWAYS_INLINE constexpr stdx::resize_simd_t<N == 0 ? V::size() : N, V>
Expand Down

0 comments on commit b9874ef

Please sign in to comment.