| 1 |
/* { dg-options "-O2 --param=aarch64-stp-policy=never -mcpu=generic" } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
typedef int v4si __attribute__ ((vector_size (16))); |
| 7 |
|
| 8 |
#define STP_TEST_ALIGNED(TYPE) \ |
| 9 |
TYPE *stp_aligned_##TYPE(char* ptr, TYPE x){ \ |
| 10 |
TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ |
| 11 |
arr[0] = x; \ |
| 12 |
arr[1] = x; \ |
| 13 |
return arr; \ |
| 14 |
} |
| 15 |
|
| 16 |
#define STP_TEST_UNALIGNED(TYPE) \ |
| 17 |
TYPE *stp_unaligned_##TYPE(char* ptr, TYPE x){ \ |
| 18 |
TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ |
| 19 |
TYPE *a = arr+1; \ |
| 20 |
a[0] = x; \ |
| 21 |
a[1] = x; \ |
| 22 |
return a; \ |
| 23 |
} |
| 24 |
|
| 25 |
#define STP_TEST_ADJUST_ALIGNED(TYPE) \ |
| 26 |
TYPE *stp_aligned_adjust_##TYPE(char* ptr, TYPE x){ \ |
| 27 |
TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ |
| 28 |
arr[100] = x; \ |
| 29 |
arr[101] = x; \ |
| 30 |
arr[102] = x; \ |
| 31 |
arr[103] = x; \ |
| 32 |
return arr; \ |
| 33 |
} |
| 34 |
|
| 35 |
#define STP_TEST_ADJUST_UNALIGNED(TYPE) \ |
| 36 |
TYPE *stp_unaligned_adjust_##TYPE(char* ptr, TYPE x){ \ |
| 37 |
TYPE *arr = (TYPE*) ((uintptr_t)ptr & ~(2 * 8 * _Alignof(TYPE) - 1)); \ |
| 38 |
TYPE *a = arr+1; \ |
| 39 |
a[100] = x; \ |
| 40 |
a[101] = x; \ |
| 41 |
a[102] = x; \ |
| 42 |
a[103] = x; \ |
| 43 |
return a; \ |
| 44 |
} |
| 45 |
|
| 46 |
STP_TEST_ALIGNED(int32_t); |
| 47 |
STP_TEST_ALIGNED(int64_t); |
| 48 |
STP_TEST_ALIGNED(v4si); |
| 49 |
STP_TEST_UNALIGNED(int32_t); |
| 50 |
STP_TEST_UNALIGNED(int64_t); |
| 51 |
STP_TEST_UNALIGNED(v4si); |
| 52 |
STP_TEST_ADJUST_ALIGNED(int32_t); |
| 53 |
STP_TEST_ADJUST_ALIGNED(int64_t); |
| 54 |
STP_TEST_ADJUST_UNALIGNED(int32_t); |
| 55 |
STP_TEST_ADJUST_UNALIGNED(int64_t); |
| 56 |
|
| 57 |
/* { dg-final { scan-assembler-times "stp\tw\[0-9\]+, w\[0-9\]" 0 } } */ |
| 58 |
/* { dg-final { scan-assembler-times "stp\tx\[0-9\]+, x\[0-9\]" 0 } } */ |
| 59 |
/* { dg-final { scan-assembler-times "stp\tq\[0-9\]+, q\[0-9\]" 0 } } */ |
| 60 |
|