| 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 ADD_TEST(TYPE) \ |
| 21 |
TYPE a_##TYPE[N * 2]; \ |
| 22 |
void __attribute__((noinline, noclone)) \ |
| 23 |
test_##TYPE (int x, int y) \ |
| 24 |
{ \ |
| 25 |
for (int i = 0; i < N; ++i) \ |
| 26 |
{ \ |
| 27 |
a_##TYPE[i + x] = i; \ |
| 28 |
a_##TYPE[i + y] = 42 - i * 2; \ |
| 29 |
} \ |
| 30 |
} |
| 31 |
|
| 32 |
#define DO_TEST(TYPE) \ |
| 33 |
for (int i = 0; i < DIST * 2; ++i) \ |
| 34 |
{ \ |
| 35 |
__builtin_memset (a_##TYPE, 0, sizeof (a_##TYPE)); \ |
| 36 |
test_##TYPE (DIST, i); \ |
| 37 |
_Pragma("GCC novector") \ |
| 38 |
for (int j = 0; j < N + DIST * 2; ++j) \ |
| 39 |
{ \ |
| 40 |
TYPE expected = 0; \ |
| 41 |
if (i > DIST && j >= i && j < i + N) \ |
| 42 |
expected = 42 - (j - i) * 2; \ |
| 43 |
if (j >= DIST && j < DIST + N) \ |
| 44 |
expected = j - DIST; \ |
| 45 |
if (i <= DIST && j >= i && j < i + N) \ |
| 46 |
expected = 42 - (j - i) * 2; \ |
| 47 |
if (expected != a_##TYPE[j]) \ |
| 48 |
__builtin_abort (); \ |
| 49 |
} \ |
| 50 |
} |
| 51 |
|
| 52 |
FOR_EACH_TYPE (ADD_TEST) |
| 53 |
|
| 54 |
int |
| 55 |
main (void) |
| 56 |
{ |
| 57 |
FOR_EACH_TYPE (DO_TEST) |
| 58 |
return 0; |
| 59 |
} |
| 60 |
|
| 61 |
/* { dg-final { scan-tree-dump {flags: *WAW\n} "vect" { target vect_int } } } */ |
| 62 |
/* { dg-final { scan-tree-dump "using an index-based WAR/WAW test" "vect" } } */ |
| 63 |
/* { dg-final { scan-tree-dump-not "using an address-based" "vect" } } */ |