PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-92.c
blobb9a1ce23d0206dba28318b9c77c13492b45b5f3e
1 /* { dg-require-effective-target vect_float } */
3 #include <stdarg.h>
4 #include "tree-vect.h"
6 #define N 256
8 float pa[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
9 float pb[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57};
10 float pc[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
12 /* Check handling of unaligned accesses when the misalignment is
13 known at compile time and different accesses have the same
14 misalignment (e.g. peeling to align one access will align all
15 accesses with the same misalignment. Also, the number of
16 peeled iterations is known in this case, and the vectorizer
17 can use this information (generate prolog and epilog loops
18 with known number of iterations, and only if needed). */
20 #if VECTOR_BITS > 128
21 #define NITER (VECTOR_BITS * 3 / 32)
22 #else
23 #define NITER 12
24 #endif
26 __attribute__ ((noinline)) int
27 main1 ()
29 int i;
31 for (i = 0; i < NITER - 2; i++)
33 pa[i+1] = pb[i+1] * pc[i+1];
36 /* check results: */
37 for (i = 0; i < 10; i++)
39 if (pa[i+1] != (pb[i+1] * pc[i+1]))
40 abort ();
43 return 0;
46 __attribute__ ((noinline)) int
47 main2 ()
49 int i;
51 for (i = 0; i < NITER; i++)
53 pa[i+1] = pb[i+1] * pc[i+1];
56 /* check results: */
57 for (i = 0; i < 12; i++)
59 if (pa[i+1] != (pb[i+1] * pc[i+1]))
60 abort ();
63 return 0;
66 __attribute__ ((noinline)) int
67 main3 (int n)
69 int i;
71 for (i = 0; i < n; i++)
73 pa[i+1] = pb[i+1] * pc[i+1];
76 /* check results: */
77 for (i = 0; i < n; i++)
79 if (pa[i+1] != (pb[i+1] * pc[i+1]))
80 abort ();
83 return 0;
86 int main (void)
88 int i;
90 check_vect ();
92 main1 ();
93 main2 ();
94 main3 (N-1);
96 return 0;
99 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 3 "vect" } } */
100 /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
101 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 3 "vect" { xfail vect_element_align_preferred } } } */