From 7e784587c274c57c63505d74e8b68380c83bff60 Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Sat, 14 Sep 2024 15:26:36 +0200 Subject: [PATCH] Workaround https://bugs.llvm.org/show_bug.cgi?id=35450 --- .../regular/impl/simd/x86/bit_ternary.hpp | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/include/eve/module/core/regular/impl/simd/x86/bit_ternary.hpp b/include/eve/module/core/regular/impl/simd/x86/bit_ternary.hpp index e2cd3fc399..bc0a6a88b7 100644 --- a/include/eve/module/core/regular/impl/simd/x86/bit_ternary.hpp +++ b/include/eve/module/core/regular/impl/simd/x86/bit_ternary.hpp @@ -22,7 +22,7 @@ namespace eve::detail template EVE_FORCEINLINE wide bit_ternary_(EVE_REQUIRES(sse2_), O const& opts, - std::integral_constant const & ik, + std::integral_constant const &, wide const& x, wide const &y, wide const &z) noexcept requires x86_abi> { @@ -31,49 +31,54 @@ namespace eve::detail auto a = bit_cast(x, as()); auto b = bit_cast(y, as()); auto c = bit_cast(z, as()); - if constexpr ( current_api < avx512 || sizeof(T) < 4) + if constexpr(current_api < avx512 || sizeof(T) < 4) { - auto doit = [opts, ik](auto a, auto b, auto c){ - if constexpr(K == 0x1b) return bit_or(bit_notand(a, c), bit_notand(c, bit_not(b))); - if constexpr(K == 0x1d) return bit_or(bit_notand(a, b), bit_notand(b, bit_not(c))); - if constexpr(K == 0x27) return bit_or(bit_notand(b, c), bit_notand(c, bit_not(a))); - if constexpr(K == 0x2e) return bit_xor(bit_or(b, c), bit_and(a, b)); - if constexpr(K == 0x35) return bit_or(bit_notand(b, a), bit_notand(a, bit_not(c))); - if constexpr(K == 0x3a) return bit_or(bit_notand(b, a), bit_notand(a, c)); - if constexpr(K == 0x47) return bit_or(bit_notand(c, b), bit_notand(b, bit_not(a))); - if constexpr(K == 0x4e) return bit_or(bit_notand(a, c), bit_notand(c, b)); - if constexpr(K == 0x53) return bit_or(bit_notand(c, a), bit_notand(a, bit_not(b))); - if constexpr(K == 0x72) return bit_or(bit_notand(b, c), bit_notand(c, a)); - if constexpr(K == 0x74) return bit_or(bit_notand(c, b), bit_notand(b, a)); - if constexpr(K == 0x8b) return bit_or(bit_and(b, c), bit_notand(b, bit_not(a))); - if constexpr(K == 0x8d) return bit_or(bit_and(c, b), bit_notand(c,bit_not(a))); - if constexpr(K == 0xa3) return bit_or(bit_and(a, c), bit_notand(a,bit_not(b))); - if constexpr(K == 0xb1) return bit_or(bit_and(a, c), bit_andnot(bit_not(b), c)); - if constexpr(K == 0xc5) return bit_or(bit_and(a, b), bit_notand(a, bit_not(c))); - if constexpr(K == 0xd1) return bit_or(bit_not(bit_or(b, c)), bit_and(a, b)); - else return bit_ternary.behavior(cpu_{}, opts, ik, a, b, c); + auto doit = [](auto const& o, auto a, auto b, auto c) + { + using c_t = std::integral_constant; + if constexpr(K == 0x1b) return bit_or(bit_notand(a, c), bit_notand(c, bit_not(b))); + else if constexpr(K == 0x1d) return bit_or(bit_notand(a, b), bit_notand(b, bit_not(c))); + else if constexpr(K == 0x27) return bit_or(bit_notand(b, c), bit_notand(c, bit_not(a))); + else if constexpr(K == 0x2e) return bit_xor(bit_or(b, c), bit_and(a, b)); + else if constexpr(K == 0x35) return bit_or(bit_notand(b, a), bit_notand(a, bit_not(c))); + else if constexpr(K == 0x3a) return bit_or(bit_notand(b, a), bit_notand(a, c)); + else if constexpr(K == 0x47) return bit_or(bit_notand(c, b), bit_notand(b, bit_not(a))); + else if constexpr(K == 0x4e) return bit_or(bit_notand(a, c), bit_notand(c, b)); + else if constexpr(K == 0x53) return bit_or(bit_notand(c, a), bit_notand(a, bit_not(b))); + else if constexpr(K == 0x72) return bit_or(bit_notand(b, c), bit_notand(c, a)); + else if constexpr(K == 0x74) return bit_or(bit_notand(c, b), bit_notand(b, a)); + else if constexpr(K == 0x8b) return bit_or(bit_and(b, c), bit_notand(b, bit_not(a))); + else if constexpr(K == 0x8d) return bit_or(bit_and(c, b), bit_notand(c,bit_not(a))); + else if constexpr(K == 0xa3) return bit_or(bit_and(a, c), bit_notand(a,bit_not(b))); + else if constexpr(K == 0xb1) return bit_or(bit_and(a, c), bit_andnot(bit_not(b), c)); + else if constexpr(K == 0xc5) return bit_or(bit_and(a, b), bit_notand(a, bit_not(c))); + else if constexpr(K == 0xd1) return bit_or(bit_not(bit_or(b, c)), bit_and(a, b)); + else return bit_ternary.behavior(cpu_{}, o, c_t{}, a, b, c); }; - return bit_cast(doit(a, b, c), as()); + return bit_cast(doit(opts,a, b, c), as()); } else { - auto doit = [ik, opts](auto x, auto y, auto z){ + auto doit = [](auto const& o, auto x, auto y, auto z) + { + using c_t = std::integral_constant; constexpr auto ca = categorize(); - if constexpr( ca == category::uint64x8 ) return _mm512_ternarylogic_epi64(x, y, z, K); + + if constexpr( ca == category::uint64x8 ) return _mm512_ternarylogic_epi64(x, y, z, K); else if constexpr( ca == category::uint64x4 ) return _mm256_ternarylogic_epi64(x, y, z, K); else if constexpr( ca == category::uint64x2 ) return _mm_ternarylogic_epi64(x, y, z, K); else if constexpr( ca == category::uint32x16) return _mm512_ternarylogic_epi32(x, y, z, K); else if constexpr( ca == category::uint32x8 ) return _mm256_ternarylogic_epi32(x, y, z, K); else if constexpr( ca == category::uint32x4 ) return _mm_ternarylogic_epi32(x, y, z, K); - else return bit_ternary.behavior(cpu_{}, opts, ik, x, y, z); + else return bit_ternary.behavior(cpu_{}, o, c_t{}, x, y, z); }; - return bit_cast(doit(a, b, c), as()); + return bit_cast(doit(opts, a, b, c), as()); } } template EVE_FORCEINLINE wide - abs_(EVE_REQUIRES(avx512_), C const& mask, O const& opts, std::integral_constant const & ik, + abs_(EVE_REQUIRES(avx512_), C const& mask, O const& opts, std::integral_constant const &, wide const& x, wide const& y, wide const& z) noexcept requires x86_abi> { auto const s = alternative(mask, x, as(x)); @@ -85,7 +90,9 @@ namespace eve::detail auto a = bit_cast(x, as()); auto b = bit_cast(y, as()); auto c = bit_cast(z, as()); - auto doit = [ik, opts, s, m](auto x, auto y, auto z){ + auto doit = [s, m](auto const& o, auto x, auto y, auto z) + { + using c_t = std::integral_constant; if constexpr( C::is_complete ) return s; else if constexpr( ca == category::uint64x8 ) return _mm512_mask_ternary_logic_epi64(s, m, x, y, z, K); else if constexpr( ca == category::uint64x4 ) return _mm256_mask_ternary_logic_epi64(s, m, x, y, z, K); @@ -93,8 +100,8 @@ namespace eve::detail else if constexpr( ca == category::uint32x16 ) return _mm512_mask_ternary_logic_epi32(s, m, x, y, z, K); else if constexpr( ca == category::uint32x8 ) return _mm256_mask_ternary_logic_epi32(s, m, x, y, z, K); else if constexpr( ca == category::uint32x4 ) return _mm_mask_ternary_logic_epi32 (s, m, x, y, z, K); - else return bit_ternary.behavior(cpu_{}, opts, ik, x, y, z); + else return bit_ternary.behavior(cpu_{}, o, c_t{}, x, y, z); }; - return bit_cast(doit(a, b, c), as()); + return bit_cast(doit(opts, a, b, c), as()); } }