]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Ensure simd types are aligned to what we assume
authorMatthew Barr <matthew.barr@intel.com>
Fri, 7 Apr 2017 06:40:11 +0000 (16:40 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Tue, 30 May 2017 03:48:38 +0000 (13:48 +1000)
Turns out Clang is sensitive to the location of the alignment attribute.

src/util/simd_types.h
unit/internal/simd_utils.cpp

index a6c87db70c058f2708fa33f5d5bc5155d79f5ffa..64844dcb3e0199459e22c6b0942fc8ce9034dc5d 100644 (file)
@@ -43,7 +43,7 @@ typedef struct ALIGN_DIRECTIVE {u64a hi; u64a lo;} m128;
 #if defined(HAVE_AVX2)
 typedef __m256i m256;
 #else
-typedef ALIGN_AVX_DIRECTIVE struct {m128 lo; m128 hi;} m256;
+typedef struct ALIGN_AVX_DIRECTIVE {m128 lo; m128 hi;} m256;
 #endif
 
 // these should align to 16 and 32 respectively
index 220d2a12c002b2bddaf5e52efe654bcfcb0a3729..dac3722ec4b5f1300db301ef5d51111bdcb60e60 100644 (file)
@@ -542,6 +542,7 @@ TYPED_TEST(SimdUtilsTest, load_store) {
 
     auto mem_ptr = make_bytecode_ptr<char>(sizeof(a), alignof(TypeParam));
     char *mem = mem_ptr.get();
+
     ASSERT_EQ(0, (size_t)mem % 16U);
 
     memset(mem, 0, sizeof(a));
@@ -585,6 +586,13 @@ TYPED_TEST(SimdUtilsTest, loadbytes_storebytes) {
     }
 }
 
+TEST(SimdUtilsTest, alignment) {
+    ASSERT_EQ(16, alignof(m128));
+    ASSERT_EQ(32, alignof(m256));
+    ASSERT_EQ(16, alignof(m384));
+    ASSERT_EQ(32, alignof(m512));
+}
+
 TEST(SimdUtilsTest, movq) {
     m128 simd;