| 1 |
#define N 200 |
| 2 |
#define DIST 32 |
| 3 |
|
| 4 |
typedef signed char sc; |
| 5 |
typedef unsigned char uc; |
| 6 |
typedef signed short ss; |
| 7 |
typedef unsigned short us; |
| 8 |
typedef int si; |
| 9 |
typedef unsigned int ui; |
| 10 |
typedef signed long long sll; |
| 11 |
typedef unsigned long long ull; |
| 12 |
|
| 13 |
#define FOR_EACH_TYPE(M) \ |
| 14 |
M (sc) M (uc) \ |
| 15 |
M (ss) M (us) \ |
| 16 |
M (si) M (ui) \ |
| 17 |
M (sll) M (ull) \ |
| 18 |
M (float) M (double) |
| 19 |
|
| 20 |
#define TEST_VALUE(I) ((I) * 11 / 2) |
| 21 |
|
| 22 |
#define ADD_TEST(TYPE) \ |
| 23 |
TYPE a_##TYPE[N * 2]; \ |
| 24 |
TYPE __attribute__((noinline, noclone)) \ |
| 25 |
test_##TYPE (int x, int y) \ |
| 26 |
{ \ |
| 27 |
TYPE res = 0; \ |
| 28 |
for (int i = 0; i < N; ++i) \ |
| 29 |
{ \ |
| 30 |
a_##TYPE[i + x] = i; \ |
| 31 |
res += a_##TYPE[i + y]; \ |
| 32 |
} \ |
| 33 |
return res; \ |
| 34 |
} |
| 35 |
|
| 36 |
#define DO_TEST(TYPE) \ |
| 37 |
_Pragma("GCC novector") \ |
| 38 |
for (int i = 0; i < DIST * 2; ++i) \ |
| 39 |
{ \ |
| 40 |
for (int j = 0; j < N + DIST * 2; ++j) \ |
| 41 |
a_##TYPE[j] = TEST_VALUE (j); \ |
| 42 |
TYPE res = test_##TYPE (DIST, i); \ |
| 43 |
_Pragma("GCC novector") \ |
| 44 |
for (int j = 0; j < N; ++j) \ |
| 45 |
if (a_##TYPE[j + DIST] != (TYPE) j) \ |
| 46 |
__builtin_abort (); \ |
| 47 |
TYPE expected_res = 0; \ |
| 48 |
for (int j = i; j < i + N; ++j) \ |
| 49 |
if (i <= DIST && j >= DIST && j < DIST + N) \ |
| 50 |
expected_res += j - DIST; \ |
| 51 |
else \ |
| 52 |
expected_res += TEST_VALUE (j); \ |
| 53 |
if (expected_res != res) \ |
| 54 |
__builtin_abort (); \ |
| 55 |
} |
| 56 |
|
| 57 |
FOR_EACH_TYPE (ADD_TEST) |
| 58 |
|
| 59 |
int |
| 60 |
main (void) |
| 61 |
{ |
| 62 |
FOR_EACH_TYPE (DO_TEST) |
| 63 |
return 0; |
| 64 |
} |
| 65 |
|
| 66 |
/* { dg-final { scan-tree-dump {flags: *RAW\n} "vect" { target vect_int } } } */ |
| 67 |
/* { dg-final { scan-tree-dump "using an index-based overlap test" "vect" } } */ |
| 68 |
/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ |