From 9e3c74088e15f5eaa45b258748c676acdabc76cf Mon Sep 17 00:00:00 2001 From: SadiinsoSnowfall Date: Thu, 26 Sep 2024 19:36:20 +0200 Subject: [PATCH] made common_logical more commutative --- include/eve/module/core/regular/logical_and.hpp | 15 ++++++++------- include/eve/traits/common_value.hpp | 2 +- test/unit/meta/traits/common_logical.cpp | 10 ++++------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/eve/module/core/regular/logical_and.hpp b/include/eve/module/core/regular/logical_and.hpp index ebff889316..fa9a492cda 100644 --- a/include/eve/module/core/regular/logical_and.hpp +++ b/include/eve/module/core/regular/logical_and.hpp @@ -77,13 +77,14 @@ namespace eve template EVE_FORCEINLINE constexpr common_logical_t logical_and_(EVE_REQUIRES(cpu_), O const&, T a, U b) noexcept { - if constexpr ((scalar_value || std::same_as) && (scalar_value || std::same_as)) return a && b; - else if constexpr (std::same_as) return logical_and(U{a}, b); - else if constexpr (std::same_as) return logical_and(a, T{b}); - else if constexpr (scalar_value && simd_value) return logical_and(as_wide_as_t{a}, b); - else if constexpr (simd_value && scalar_value) return logical_and(a, T{b}); - else if constexpr (std::same_as) return bit_cast(a.bits() & b.bits(), as>{}); - else return logical_and(a, convert(b, as{})); + if constexpr ((scalar_value || std::same_as) + && (scalar_value || std::same_as)) return a && b; + else if constexpr (std::same_as) return logical_and(U{a}, b); + else if constexpr (std::same_as) return logical_and(a, T{b}); + else if constexpr (simd_value && scalar_value) return logical_and(a, T{b}); + else if constexpr (scalar_value && simd_value) return logical_and(b, U{a}); + else if constexpr (std::same_as) return bit_cast(a.bits() & b.bits(), as>{}); + else return logical_and(a, convert(b, as{})); } } } diff --git a/include/eve/traits/common_value.hpp b/include/eve/traits/common_value.hpp index 43b17d1f00..f6519f8c8a 100644 --- a/include/eve/traits/common_value.hpp +++ b/include/eve/traits/common_value.hpp @@ -97,10 +97,10 @@ namespace eve::detail ) { if constexpr (std::same_as && std::same_as) return find_common_logical_reducer{}; else if constexpr (simd_value) return find_common_logical_reducer>{}; + else if constexpr (simd_value) return find_common_logical_reducer>{}; else if constexpr (std::same_as) return find_common_logical_reducer>{}; else if constexpr (std::same_as) return find_common_logical_reducer>{}; else if constexpr (scalar_value) return find_common_logical_reducer>{}; - else if constexpr (simd_value) return find_common_logical_reducer>>{}; else return find_common_logical_reducer{}; } }; diff --git a/test/unit/meta/traits/common_logical.cpp b/test/unit/meta/traits/common_logical.cpp index 50fb278a59..32d61b9703 100644 --- a/test/unit/meta/traits/common_logical.cpp +++ b/test/unit/meta/traits/common_logical.cpp @@ -64,17 +64,15 @@ TTS_CASE_TPL("eve::common_logical on wide x wide" using Wt = eve::wide; using Wu = eve::wide; - using uWt = eve::as_wide_as_t; - TTS_TYPE_IS((eve::common_logical_t), eve::logical); TTS_TYPE_IS((eve::common_logical_t>), eve::logical); TTS_TYPE_IS((eve::common_logical_t, Wu>), eve::logical); TTS_TYPE_IS((eve::common_logical_t, eve::logical>), eve::logical); - TTS_TYPE_IS((eve::common_logical_t), eve::logical); - TTS_TYPE_IS((eve::common_logical_t>), eve::logical); - TTS_TYPE_IS((eve::common_logical_t, Wu>), eve::logical); - TTS_TYPE_IS((eve::common_logical_t, eve::logical>), eve::logical); + TTS_TYPE_IS((eve::common_logical_t), eve::logical); + TTS_TYPE_IS((eve::common_logical_t>), eve::logical); + TTS_TYPE_IS((eve::common_logical_t, Wu>), eve::logical); + TTS_TYPE_IS((eve::common_logical_t, eve::logical>), eve::logical); TTS_TYPE_IS((eve::common_logical_t), eve::logical); TTS_TYPE_IS((eve::common_logical_t>), eve::logical);