Skip to content

Commit 5af6bcd

Browse files
Use aligned load instead of unaligned load during testing
Doing so avoids exercising unaligned load during unrelated test.
1 parent 8bddb04 commit 5af6bcd

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

test/test_utils.hpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ namespace xsimd
152152
template <class T, class A, size_t N>
153153
inline bool operator==(const batch<T, A>& lhs, const std::array<T, N>& rhs)
154154
{
155-
std::array<T, N> tmp;
156-
lhs.store_unaligned(tmp.data());
155+
alignas(A::alignment()) std::array<T, N> tmp;
156+
lhs.store_aligned(tmp.data());
157157
return tmp == rhs;
158158
}
159159

@@ -166,8 +166,8 @@ namespace xsimd
166166
template <class T, class A, size_t N, bool i3ec>
167167
inline bool operator==(const batch<std::complex<T>, A>& lhs, const std::array<xtl::xcomplex<T, T, i3ec>, N>& rhs)
168168
{
169-
std::array<xtl::xcomplex<T, T, i3ec>, N> tmp;
170-
lhs.store_unaligned(tmp.data());
169+
alignas(A::alignment()) std::array<xtl::xcomplex<T, T, i3ec>, N> tmp;
170+
lhs.store_aligned(tmp.data());
171171
return tmp == rhs;
172172
}
173173

@@ -401,50 +401,50 @@ namespace detail
401401
template <class T, size_t N, class A>
402402
bool expect_batch_near(const ::xsimd::batch<T, A>& lhs, const std::array<T, N>& rhs)
403403
{
404-
std::array<T, N> tmp;
405-
lhs.store_unaligned(tmp.data());
404+
alignas(A::alignment()) std::array<T, N> tmp;
405+
lhs.store_aligned(tmp.data());
406406
return expect_array_near(tmp, rhs);
407407
}
408408

409409
template <class T, size_t N, class A>
410410
bool expect_batch_near(const std::array<T, N>& lhs, const ::xsimd::batch<T, A>& rhs)
411411
{
412-
std::array<T, N> tmp;
413-
rhs.store_unaligned(tmp.data());
412+
alignas(A::alignment()) std::array<T, N> tmp;
413+
rhs.store_aligned(tmp.data());
414414
return expect_array_near(lhs, tmp);
415415
}
416416

417417
template <class T, class A>
418418
bool expect_batch_near(const ::xsimd::batch<T, A>& lhs, const ::xsimd::batch<T, A>& rhs)
419419
{
420420
constexpr auto N = xsimd::batch<T, A>::size;
421-
std::array<T, N> tmp;
422-
lhs.store_unaligned(tmp.data());
421+
alignas(A::alignment()) std::array<T, N> tmp;
422+
lhs.store_aligned(tmp.data());
423423
return expect_batch_near(tmp, rhs);
424424
}
425425

426426
template <class T, size_t N, class A>
427427
bool expect_batch_near(const ::xsimd::batch_bool<T, A>& lhs, const std::array<bool, N>& rhs)
428428
{
429-
std::array<bool, N> tmp;
430-
lhs.store_unaligned(tmp.data());
429+
alignas(A::alignment()) std::array<bool, N> tmp;
430+
lhs.store_aligned(tmp.data());
431431
return expect_array_near(tmp, rhs);
432432
}
433433

434434
template <class T, size_t N, class A>
435435
bool expect_batch_near(const std::array<bool, N>& lhs, const ::xsimd::batch_bool<T, A>& rhs)
436436
{
437-
std::array<bool, N> tmp;
438-
rhs.store_unaligned(tmp.data());
437+
alignas(A::alignment()) std::array<bool, N> tmp;
438+
rhs.store_aligned(tmp.data());
439439
return expect_array_near(lhs, tmp);
440440
}
441441

442442
template <class T, class A>
443443
bool expect_batch_near(const ::xsimd::batch_bool<T, A>& lhs, const ::xsimd::batch_bool<T, A>& rhs)
444444
{
445445
constexpr auto N = xsimd::batch<T, A>::size;
446-
std::array<bool, N> tmp;
447-
lhs.store_unaligned(tmp.data());
446+
alignas(A::alignment()) std::array<bool, N> tmp;
447+
lhs.store_aligned(tmp.data());
448448
return expect_batch_near(tmp, rhs);
449449
}
450450

0 commit comments

Comments
 (0)