libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-alias-check-16.c
blobd90adc70e28420e5e8fd0e36c15316da12224b38
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) * 13 / 2)
22 #define ADD_TEST(TYPE) \
23 TYPE __attribute__((noinline, noclone)) \
24 test_##TYPE (TYPE *x, TYPE *y) \
25 { \
26 TYPE res = 0; \
27 for (int i = 0; i < N; ++i) \
28 { \
29 x[i] = i; \
30 res += y[i]; \
31 } \
32 return res; \
35 #define DO_TEST(TYPE) \
36 _Pragma("GCC novector") \
37 for (int i = 0; i < DIST * 2; ++i) \
38 { \
39 TYPE a[N + DIST * 2]; \
40 for (int j = 0; j < N + DIST * 2; ++j) \
41 a[j] = TEST_VALUE (j); \
42 TYPE res = test_##TYPE (a + DIST, a + i); \
43 _Pragma("GCC novector") \
44 for (int j = 0; j < N; ++j) \
45 if (a[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 address-based overlap test" "vect" { target { ! vect_check_ptrs } } } } */
68 /* { dg-final { scan-tree-dump "using an IFN_CHECK_RAW_PTRS test" "vect" { target vect_check_ptrs } } } */
69 /* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */