| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx2 -mno-avx512f" } */ |
| 3 |
/* { dg-require-effective-target avx2 } */ |
| 4 |
|
| 5 |
#ifndef CHECK_H |
| 6 |
#define CHECK_H "avx2-check.h" |
| 7 |
#endif |
| 8 |
|
| 9 |
#ifndef TEST |
| 10 |
#define TEST avx2_test |
| 11 |
#endif |
| 12 |
|
| 13 |
#include CHECK_H |
| 14 |
|
| 15 |
typedef long long V __attribute__((vector_size (32))); |
| 16 |
|
| 17 |
#define TESTN(N) \ |
| 18 |
static V \ |
| 19 |
__attribute__((noipa)) \ |
| 20 |
test##N (V x) \ |
| 21 |
{ \ |
| 22 |
return x >> N; \ |
| 23 |
} |
| 24 |
|
| 25 |
#define TESTS TESTN (63) TESTN (49) TESTN (32) TESTN (31) TESTN (18) |
| 26 |
TESTS |
| 27 |
|
| 28 |
struct |
| 29 |
{ |
| 30 |
int n; |
| 31 |
V (*fn) (V); |
| 32 |
} tests[] = { |
| 33 |
#undef TESTN |
| 34 |
#define TESTN(N) { N, test##N }, |
| 35 |
TESTS |
| 36 |
}; |
| 37 |
|
| 38 |
static void |
| 39 |
TEST (void) |
| 40 |
{ |
| 41 |
V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL, |
| 42 |
0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL }; |
| 43 |
int i; |
| 44 |
for (i = 0; i < ARRAY_SIZE (tests); i++) |
| 45 |
{ |
| 46 |
V c = tests[i].fn (a); |
| 47 |
if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n |
| 48 |
|| c[2] != a[2] >> tests[i].n || c[3] != a[3] >> tests[i].n) |
| 49 |
abort (); |
| 50 |
} |
| 51 |
} |