Skip to content

Commit

Permalink
changed common_logical behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
SadiinsoSnowfall committed Nov 29, 2024
1 parent b012592 commit fe64b25
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
6 changes: 5 additions & 1 deletion include/eve/module/core/regular/logical_and.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ namespace eve
else if constexpr (std::same_as<T, bool>) return logical_and(U{a}, b);
else if constexpr (std::same_as<U, bool>) return logical_and(a, T{b});
else if constexpr (logical_simd_value<T> && scalar_value<U>) return logical_and(a, T{b});
else if constexpr (scalar_value<T> && logical_simd_value<U>) return logical_and(b, U{a});
else if constexpr (scalar_value<T> && logical_simd_value<U>)
{
using lw_t = as_logical_t<as_wide_as_t<T, U>>;
return logical_and(lw_t{a}, lw_t{b});
}
else if constexpr (std::same_as<typename T::bits_type, typename U::bits_type>)
{
if constexpr (scalar_value<T> && scalar_value<U>) return T{a && b};
Expand Down
2 changes: 1 addition & 1 deletion include/eve/traits/common_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ namespace eve::detail
) {
if constexpr (std::same_as<T, bool> && std::same_as<U, bool>) return find_common_logical_reducer<bool>{};
else if constexpr (simd_value<T>) return find_common_logical_reducer<as_logical_t<T>>{};
else if constexpr (simd_value<U>) return find_common_logical_reducer<as_logical_t<U>>{};
else if constexpr (std::same_as<T, bool>) return find_common_logical_reducer<as_logical_t<U>>{};
else if constexpr (std::same_as<U, bool>) return find_common_logical_reducer<as_logical_t<T>>{};
else if constexpr (simd_value<U>) return find_common_logical_reducer<as_logical_t<as_wide_as_t<T, U>>>{};
else if constexpr (scalar_value<U>) return find_common_logical_reducer<as_logical_t<T>>{};
else return find_common_logical_reducer<void>{};
}
Expand Down
31 changes: 17 additions & 14 deletions test/unit/meta/traits/common_logical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,24 @@ TTS_CASE_TPL("eve::common_logical on wide x wide"
)
<typename T, typename U>( tts::type<kumi::tuple<T, U>> )
{
using Wt = eve::wide<T>;
using Wu = eve::wide<U>;
using Wt = eve::wide<T, eve::fixed<4>>;
using Wu = eve::wide<U, eve::fixed<4>>;
using LWt = eve::logical<Wt>;
using LWu = eve::logical<Wu>;

TTS_TYPE_IS((eve::common_logical_t<Wt, Wu>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<Wt, eve::logical<Wu>>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<Wt>, Wu>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<Wt>, eve::logical<Wu>>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<Wt, Wu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<Wt, LWu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<LWt, Wu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<LWt, LWu>), LWt);

TTS_TYPE_IS((eve::common_logical_t<T, Wu>), eve::logical<Wu>);
TTS_TYPE_IS((eve::common_logical_t<T, eve::logical<Wu>>), eve::logical<Wu>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<T>, Wu>), eve::logical<Wu>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<T>, eve::logical<Wu>>), eve::logical<Wu>);
// ensure compatibility with eve::detail::map
TTS_TYPE_IS((eve::common_logical_t<T, Wu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<T, LWu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<T>, Wu>), LWt);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<T>, LWu>), LWt);

TTS_TYPE_IS((eve::common_logical_t<Wt, U>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<Wt, eve::logical<U>>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<Wt>, U>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<eve::logical<Wt>, eve::logical<U>>), eve::logical<Wt>);
TTS_TYPE_IS((eve::common_logical_t<Wt, U>), LWt);
TTS_TYPE_IS((eve::common_logical_t<Wt, eve::logical<U>>), LWt);
TTS_TYPE_IS((eve::common_logical_t<LWt, U>), LWt);
TTS_TYPE_IS((eve::common_logical_t<LWt, eve::logical<U>>), LWt);
};

0 comments on commit fe64b25

Please sign in to comment.