Skip to content

Commit

Permalink
sve masked load issues (#1491)
Browse files Browse the repository at this point in the history
* sve: unit.memory.exe

* Fix fixed<0> in x86 arithmetic

Co-authored-by: Joel Falcou <[email protected]>
  • Loading branch information
DenisYaroshevskiy and jfalcou authored Dec 19, 2022
1 parent f5bf7da commit 635277d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
44 changes: 20 additions & 24 deletions include/eve/detail/function/simd/arm/sve/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,46 @@ template<relative_conditional_expr C,
typename N,
simd_compatible_ptr<wide<T, N>> Ptr>
EVE_FORCEINLINE wide<T, N>
load_(EVE_SUPPORTS(sve_), C const& cond, safe_type const&, eve::as<wide<T, N>> const&, Ptr p)
requires(sve_abi<abi_t<T, N>>)
load_(EVE_SUPPORTS(sve_),
C const& cond, safe_type const& s, eve::as<wide<T, N>> const& tgt, Ptr p)
requires (!has_bundle_abi_v<wide<T, N>>)
{
auto ptr = unalign(p);

if constexpr(C::is_complete && C::is_inverted)
if constexpr ( C::has_alternative )
{
if constexpr( N() == expected_cardinal_v<T> ) return svld1(sve_true<T>(), ptr);
else return svldff1(sve_true<T>(), ptr);
auto res = load(drop_alternative(cond), s, tgt, p);
return eve::replace_ignored(res, cond, cond.alternative);
}
else
else if constexpr ( C::is_complete && !C::is_inverted ) return {};
else if constexpr ( has_aggregated_abi_v<wide<T, N>> )
{
wide<T, N> loaded;
using half = wide<T, typename N::split_type>;

if constexpr(!C::is_complete)
{
auto mask = cond.mask(as<wide<T,N>>{});
if constexpr( N() == expected_cardinal_v<T> ) loaded = svld1(mask, ptr);
else loaded = svldff1(mask, ptr);
if constexpr( C::has_alternative )
{
loaded = svsel(mask, loaded, wide<T,N>(cond.alternative));
}
}
else
{
if constexpr( C::has_alternative ) loaded = wide<T,N>(cond.alternative);
}
// condition does not matter - just presense matters
auto lo = load(cond, s, as<half>{}, ptr);
auto hi = load(cond, s, as<half>{}, ptr + half::size());

return loaded;
return {lo, hi};
}
else if constexpr(C::is_complete && C::is_inverted && N() == expected_cardinal_v<T> )
{
return svld1(sve_true<T>(), ptr);
}
else return svldff1(sve_true<T>(), ptr);
}

//================================================================================================
// Logical support
//================================================================================================
template<relative_conditional_expr C, typename T, typename N, data_source Pointer>
template<relative_conditional_expr C, typename T, typename N,
simd_compatible_ptr<logical<wide<T, N>>> Pointer>
EVE_FORCEINLINE logical<wide<T, N>>
load_(EVE_SUPPORTS(sve_),
C const& cond,
safe_type const&,
eve::as<logical<wide<T, N>>> const&,
Pointer ptr) noexcept
requires(dereference_as<logical<T>, Pointer>::value && sve_abi<abi_t<T, N>>)
{
auto const c1 = map_alternative(cond, [](auto alt) { return alt.mask(); });
auto const block = load(c1, safe, eve::as<wide<T, N>> {}, ptr_cast<T const>(ptr));
Expand Down
6 changes: 4 additions & 2 deletions include/eve/detail/function/simd/x86/arithmetic_compounds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ namespace eve::detail
}
else
{
using htype = wide<std::int64_t, fixed<N::value / 2>>;
static constexpr auto half_size = (N::value/2 > 0) ? N::value/2 : 1;
using htype = wide<std::int64_t, fixed<half_size>>;
htype mhi = _mm_setr_epi32(-1, 0, -1, 0);
htype mlo = mhi;
auto lself = _mm_srli_si128(self, 4);
Expand All @@ -202,7 +203,8 @@ namespace eve::detail
else if constexpr( c == category::uint16x8 ) self = _mm_mullo_epi16(self, other);
else if constexpr( c == category::int8x16 || c == category::uint8x16 )
{
using htype = wide<std::int16_t, fixed<N::value / 2>>;
static constexpr auto half_size = (N::value/2 > 0) ? N::value/2 : 1;
using htype = wide<std::int16_t, fixed<half_size>>;
htype mhi = _mm_set1_epi16(0x00FF);
htype mlo = mhi;
auto lself = _mm_srli_epi16(self, 8);
Expand Down

0 comments on commit 635277d

Please sign in to comment.