2018-01-16 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-alias-check-12.c
bloba44c9bb52587747a9457a4a1b2c61c089ce60d4f
1 /* { dg-do run } */
3 #define N 87
4 #define M 7
6 typedef signed char sc;
7 typedef unsigned char uc;
8 typedef signed short ss;
9 typedef unsigned short us;
10 typedef int si;
11 typedef unsigned int ui;
12 typedef signed long long sll;
13 typedef unsigned long long ull;
15 #define FOR_EACH_TYPE(M) \
16 M (sc) M (uc) \
17 M (ss) M (us) \
18 M (si) M (ui) \
19 M (sll) M (ull) \
20 M (float) M (double)
22 #define TEST_VALUE1(I) ((I) * 5 / 2)
23 #define TEST_VALUE2(I) ((I) * 11 / 5)
25 #define ADD_TEST(TYPE) \
26 void __attribute__((noinline, noclone)) \
27 test_##TYPE (TYPE *restrict a, TYPE *restrict b, \
28 int step) \
29 { \
30 step = step & M; \
31 for (int i = 0; i < N; ++i) \
32 { \
33 TYPE r1 = a[i * step + 0] += 1; \
34 a[i * step + 1] += 2; \
35 a[i * step + 2] += 4; \
36 a[i * step + 3] += 8; \
37 b[i] += r1; \
38 } \
39 } \
41 void __attribute__((noinline, noclone)) \
42 ref_##TYPE (TYPE *restrict a, TYPE *restrict b, \
43 int step) \
44 { \
45 for (unsigned short i = 0; i < N; ++i) \
46 { \
47 TYPE r1 = a[i * step + 0] += 1; \
48 a[i * step + 1] += 2; \
49 a[i * step + 2] += 4; \
50 a[i * step + 3] += 8; \
51 b[i] += r1; \
52 asm volatile (""); \
53 } \
56 #define DO_TEST(TYPE) \
57 for (int j = 0; j <= M; ++j) \
58 { \
59 TYPE a1[N * M], a2[N * M], b1[N], b2[N]; \
60 for (int i = 0; i < N * M; ++i) \
61 a1[i] = a2[i] = TEST_VALUE1 (i); \
62 for (int i = 0; i < N; ++i) \
63 b1[i] = b2[i] = TEST_VALUE2 (i); \
64 test_##TYPE (a1, b1, j); \
65 ref_##TYPE (a2, b2, j); \
66 if (__builtin_memcmp (a1, a2, sizeof (a1)) != 0) \
67 __builtin_abort (); \
68 if (__builtin_memcmp (b1, b2, sizeof (b1)) != 0) \
69 __builtin_abort (); \
72 FOR_EACH_TYPE (ADD_TEST)
74 int
75 main (void)
77 FOR_EACH_TYPE (DO_TEST)
78 return 0;
81 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 2\)} "vect" { target vect_int } } } */
82 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 3\)} "vect" { target vect_int } } } */
83 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* is outside \[0, 4\)} "vect" { target vect_int } } } */
84 /* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]*\) >= 4} "vect" { target vect_int } } } */
86 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 4\)} "vect" { target vect_int } } } */
87 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 6\)} "vect" { target vect_int } } } */
88 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 2[)]* is outside \[0, 8\)} "vect" { target vect_int } } } */
89 /* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 2[)]* >= 8} "vect" { target vect_int } } } */
91 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 8\)} "vect" { target { vect_int || vect_float } }} } */
92 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 12\)} "vect" { target { vect_int || vect_float } }} } */
93 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 4[)]* is outside \[0, 16\)} "vect" { target { vect_int || vect_float } }} } */
94 /* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 4[)]* >= 16} "vect" { target { vect_int || vect_float } }} } */
96 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 16\)} "vect" { target vect_double } } } */
97 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 24\)} "vect" { target vect_double } } } */
98 /* { dg-final { scan-tree-dump {no alias between [^\n]* when [^\n]* [_a-z][^ ]* \* 8[)]* is outside \[0, 32\)} "vect" { target vect_double } } } */
99 /* { dg-final { scan-tree-dump {run-time check [^\n]* unsigned \([^*]* \* 8[)]* >= 32} "vect" { target vect_double } } } */