arm: fix typo in dg-require-effective-target [PR118089]
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-tail-nomask-1.c
blob116a7aefca6c362460710eeb76937570aeb9ed01
1 /* { dg-skip-if "No undefined weak" { ! { posix_memalign } } } */
2 /* { dg-additional-options "--param vect-epilogues-nomask=1 -mavx2" { target avx2_runtime } } */
4 #define SIZE 1023
5 #define ALIGN 64
7 extern int posix_memalign(void **memptr, __SIZE_TYPE__ alignment, __SIZE_TYPE__ size);
8 extern void free (void *);
10 void __attribute__((noinline))
11 test_citer (int * __restrict__ a,
12 int * __restrict__ b,
13 int * __restrict__ c)
15 int i;
17 a = (int *)__builtin_assume_aligned (a, ALIGN);
18 b = (int *)__builtin_assume_aligned (b, ALIGN);
19 c = (int *)__builtin_assume_aligned (c, ALIGN);
21 for (i = 0; i < SIZE; i++)
22 c[i] = a[i] + b[i];
25 void __attribute__((noinline))
26 test_viter (int * __restrict__ a,
27 int * __restrict__ b,
28 int * __restrict__ c,
29 int size)
31 int i;
33 a = (int *)__builtin_assume_aligned (a, ALIGN);
34 b = (int *)__builtin_assume_aligned (b, ALIGN);
35 c = (int *)__builtin_assume_aligned (c, ALIGN);
37 for (i = 0; i < size; i++)
38 c[i] = a[i] + b[i];
41 void __attribute__((noinline))
42 init_data (int * __restrict__ a,
43 int * __restrict__ b,
44 int * __restrict__ c,
45 int size)
47 for (int i = 0; i < size; i++)
49 a[i] = i;
50 b[i] = -i;
51 c[i] = 0;
52 asm volatile("": : :"memory");
54 a[size] = b[size] = c[size] = size;
58 void __attribute__((noinline))
59 run_test ()
61 int *a;
62 int *b;
63 int *c;
64 int i;
66 if (posix_memalign ((void **)&a, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
67 return;
68 if (posix_memalign ((void **)&b, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
69 return;
70 if (posix_memalign ((void **)&c, ALIGN, (SIZE + 1) * sizeof (int)) != 0)
71 return;
73 init_data (a, b, c, SIZE);
74 test_citer (a, b, c);
75 #pragma GCC novector
76 for (i = 0; i < SIZE; i++)
77 if (c[i] != a[i] + b[i])
78 __builtin_abort ();
79 if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
80 __builtin_abort ();
82 init_data (a, b, c, SIZE);
83 test_viter (a, b, c, SIZE);
84 #pragma GCC novector
85 for (i = 0; i < SIZE; i++)
86 if (c[i] != a[i] + b[i])
87 __builtin_abort ();
88 if (a[SIZE] != SIZE || b[SIZE] != SIZE || c[SIZE] != SIZE)
89 __builtin_abort ();
91 free (a);
92 free (b);
93 free (c);
96 int
97 main (int argc, const char **argv)
99 run_test ();
100 return 0;
103 /* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 2 "vect" { target avx2_runtime } } } */
104 /* { dg-final { scan-tree-dump-times "LOOP EPILOGUE VECTORIZED \\(MODE=V16QI\\)" 2 "vect" { target avx2_runtime } } } */