Skip to content

Commit

Permalink
test: Fix data alignment on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
p12tic committed Oct 29, 2017
1 parent 72bf095 commit cf21b74
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/insn/memory_load.cc
Expand Up @@ -24,8 +24,11 @@ void test_load_helper(TestResultsSet& tc, TestReporter& tr, void* sv_p)
std::memcpy(sv, sv_p, sizeof(V) * vnum);

// On certain architectures, e.g. armv7 NEON, 128 bit vectors are not
// necessarily aligned to 16 bytes on the stack
SIMDPP_ALIGN(sizeof(V)) V rv[vnum];
// necessarily aligned to 16 bytes on the stack.
// NOTE: MSVC 2013 does not support constant expressions within
// SIMDPP_ALIGN, thus we're aligning to the alignment of the largest V
// is going to be instantiated with
SIMDPP_ALIGN(64) V rv[vnum];

auto rzero = [&](V* r)
{
Expand Down
18 changes: 16 additions & 2 deletions test/insn/memory_store.cc
Expand Up @@ -17,7 +17,13 @@ template<class V>
void test_store_masked(TestResultsSet& tc, TestReporter& tr, const V* sv)
{
using namespace simdpp;
SIMDPP_ALIGN(16) V rv[1];

// On certain architectures, e.g. armv7 NEON, 128 bit vectors are not
// necessarily aligned to 16 bytes on the stack.
// NOTE: MSVC 2013 does not support constant expressions within
// SIMDPP_ALIGN, thus we're aligning to the alignment of the largest V
// is going to be instantiated with
SIMDPP_ALIGN(64) V rv[1];

tc.reset_seq();
TestData<V> mask_data;
Expand Down Expand Up @@ -48,8 +54,16 @@ void test_store_helper(TestResultsSet& tc, TestReporter& tr, const V* sv)
V zero = make_zero();

// On certain architectures, e.g. armv7 NEON, 128 bit vectors are not
// necessarily aligned to 16 bytes on the stack
// necessarily aligned to 16 bytes on the stack.
// NOTE: MSVC 2013 does not support constant expressions within
// SIMDPP_ALIGN, thus we're aligning to the alignment of the largest V
// is going to be instantiated with
#if SIMDPP_USE_ALTIVEC
// Force-aligning to 64 bytes exposes a bug in GCC on Altivec
SIMDPP_ALIGN(16) V rv[vnum];
#else
SIMDPP_ALIGN(64) V rv[vnum];
#endif
auto rdata = reinterpret_cast<typename V::element_type*>(rv);

auto rzero = [](V* r)
Expand Down

0 comments on commit cf21b74

Please sign in to comment.