libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-alias-check-14.c
blobb36ad116762e2e3c90ccd79fc4f8564cc57fc3f1
1 #define N 200
2 #define M 4
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) * 17 / 2)
22 #define ADD_TEST(TYPE) \
23 void __attribute__((noinline, noclone)) \
24 test_##TYPE (TYPE *a, TYPE *b) \
25 { \
26 for (int i = 0; i < N; i += 2) \
27 { \
28 TYPE b0 = b[i + 0]; \
29 TYPE b1 = b[i + 1]; \
30 a[i + 0] = b0 + 2; \
31 a[i + 1] = b1 + 3; \
32 } \
35 #define DO_TEST(TYPE) \
36 for (int j = 0; j < M; ++j) \
37 { \
38 TYPE a[N + M]; \
39 for (int i = 0; i < N + M; ++i) \
40 a[i] = TEST_VALUE (i); \
41 test_##TYPE (a + j, a); \
42 _Pragma("GCC novector") \
43 for (int i = 0; i < N; i += 2) \
44 { \
45 TYPE base1 = j == 0 ? TEST_VALUE (i) : a[i]; \
46 TYPE base2 = j <= 1 ? TEST_VALUE (i + 1) : a[i + 1]; \
47 if (a[i + j] != (TYPE) (base1 + 2) \
48 || a[i + j + 1] != (TYPE) (base2 + 3)) \
49 __builtin_abort (); \
50 } \
53 FOR_EACH_TYPE (ADD_TEST)
55 int
56 main (void)
58 FOR_EACH_TYPE (DO_TEST)
59 return 0;
62 /* { dg-final { scan-tree-dump {flags: *WAR\n} "vect" { target vect_int } } } */
63 /* { dg-final { scan-tree-dump-not {flags: [^\n]*ARBITRARY\n} "vect" } } */
64 /* { dg-final { scan-tree-dump "using an address-based WAR/WAW test" "vect" { target { ! vect_check_ptrs } } } } */
65 /* { dg-final { scan-tree-dump "using an IFN_CHECK_WAR_PTRS test" "vect" { target vect_check_ptrs } } } */
66 /* { dg-final { scan-tree-dump-not "using an index-based" "vect" } } */