libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-alias-check-20.c
blob9658f8ce38e8efb8d19806a4078e1dc4fe57d2ef
1 #define N 200
2 #define DIST 32
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;
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)
20 #define TEST_VALUE(I) ((I) * 11 / 2)
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; \
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 (); \
57 FOR_EACH_TYPE (ADD_TEST)
59 int
60 main (void)
62 FOR_EACH_TYPE (DO_TEST)
63 return 0;
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" } } */