Skip to content

Commit 60ca510

Browse files
Extra masked load/store testing
1 parent 0e78b8b commit 60ca510

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

test/test_load_store.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ struct load_store_test
2424
using batch_type = B;
2525
using value_type = typename B::value_type;
2626
using index_type = typename xsimd::as_integer_t<batch_type>;
27-
using batch_bool_type = typename batch_type::batch_bool_type;
2827
template <class T>
2928
using allocator = xsimd::default_allocator<T, typename B::arch_type>;
3029
static constexpr size_t size = B::size;
@@ -605,4 +604,34 @@ TEST_CASE_TEMPLATE("[load store]", B, BATCH_TYPES)
605604
SUBCASE("masked") { Test.test_masked(); }
606605
}
607606

607+
TEST_CASE_TEMPLATE("store_masked respects Mode", B, BATCH_TYPES)
608+
{
609+
using T = typename B::value_type;
610+
using A = typename B::arch_type;
611+
constexpr std::size_t N = B::size;
612+
613+
// Unaligned-mode + unaligned pointer: must not fault.
614+
alignas(A::alignment()) T big[2 * N + 1] = {};
615+
T* unaligned_ptr = big + 1; // sizeof(T)-aligned only
616+
617+
struct AllTrue
618+
{
619+
static constexpr bool get(std::size_t, std::size_t) { return true; }
620+
};
621+
auto cst_mask = xsimd::make_batch_bool_constant<T, AllTrue, A>();
622+
623+
B v(T(7));
624+
v.store(unaligned_ptr, cst_mask, xsimd::unaligned_mode {});
625+
for (std::size_t i = 0; i < N; ++i)
626+
CHECK_EQ(unaligned_ptr[i], T(7));
627+
628+
// Overload resolution: store_masked with same-typed mask must compile.
629+
// If C3 regresses, this becomes a compile error.
630+
auto signed_cst_mask = xsimd::make_batch_bool_constant<T, AllTrue, A>();
631+
alignas(A::alignment()) T aligned_buf[N] = {};
632+
v.store(aligned_buf, signed_cst_mask, xsimd::aligned_mode {});
633+
for (std::size_t i = 0; i < N; ++i)
634+
CHECK_EQ(aligned_buf[i], T(7));
635+
}
636+
608637
#endif

0 commit comments

Comments
 (0)