Mercurial > vec
annotate test/test_align.h @ 4:75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
author | Paper <paper@tflc.us> |
---|---|
date | Wed, 23 Oct 2024 10:13:25 -0400 |
parents | 3c5545b1568f |
children | 6ff0b7a44bb6 |
rev | line source |
---|---|
3 | 1 static int test_align(void) |
2 { | |
3 int ret = 0; | |
4 | |
5 #define RUN_TEST(sign, csign, bits, size) \ | |
6 do { \ | |
7 /* allocate the aligned array */ \ | |
8 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(vec_arr); \ | |
9 \ | |
10 /* fill the values */ \ | |
11 for (int i = 0; i < V##csign##INT##bits##x##size##_ALIGNED_ARRAY_LENGTH(vec_arr); i++) \ | |
12 vec_arr[i] = i; \ | |
13 \ | |
14 /* try to load it */ \ | |
15 v##sign##int##bits##x##size vec = v##sign##int##bits##x##size##_load_aligned(vec_arr); \ | |
16 \ | |
17 /* now allocate an output array */ \ | |
18 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(vec_arr_out); \ | |
19 \ | |
20 /* try storing it */ \ | |
21 v##sign##int##bits##x##size##_store_aligned(vec, vec_arr_out); \ | |
22 \ | |
23 /* mark success or failure */ \ | |
24 ret |= !!memcmp(vec_arr, vec_arr_out, V##csign##INT##bits##x##size##_ALIGNED_ARRAY_LENGTH(vec_arr)); \ | |
4
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
25 \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
26 ret |= !V##csign##INT##bits##x##size##_PTR_ALIGNED(vec_arr); \ |
75ab77f874e2
*: aligned generics, fixed altivec, aligned tests...
Paper <paper@tflc.us>
parents:
3
diff
changeset
|
27 ret |= !V##csign##INT##bits##x##size##_PTR_ALIGNED(vec_arr_out); \ |
3 | 28 } while (0); |
29 | |
30 #define RUN_TESTS(bits, size) \ | |
31 RUN_TEST( , , bits, size) \ | |
32 RUN_TEST(u, U, bits, size) | |
33 | |
34 RUN_TESTS(8, 16) | |
35 RUN_TESTS(16, 8) | |
36 RUN_TESTS(32, 4) | |
37 RUN_TESTS(64, 2) | |
38 | |
39 #undef RUN_TESTS | |
40 #undef RUN_TEST | |
41 | |
42 return ret; | |
43 } |