PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / slp-cond-2.c
blob7350695ece0f53e36de861c4e7724ebf36ff6b76
1 /* { dg-require-effective-target vect_cond_mixed } */
2 /* { dg-require-effective-target vect_float } */
4 #include "tree-vect.h"
6 #define N 32
7 int d[N], e[N], f[N];
8 unsigned char k[N];
9 float a[N], b[N];
11 __attribute__((noinline, noclone)) void
12 f1 (void)
14 int i;
15 for (i = 0; i < N/4; i++)
17 k[4*i] = a[4*i] < b[4*i] ? 17 : 0;
18 k[4*i+1] = a[4*i+1] < b[4*i+1] ? 17 : 0;
19 k[4*i+2] = a[4*i+2] < b[4*i+2] ? 17 : 0;
20 k[4*i+3] = a[4*i+3] < b[4*i+3] ? 17 : 0;
24 __attribute__((noinline, noclone)) void
25 f2 (void)
27 int i;
28 for (i = 0; i < N/2; ++i)
30 k[2*i] = a[2*i] < b[2*i] ? 0 : 24;
31 k[2*i+1] = a[2*i+1] < b[2*i+1] ? 7 : 4;
35 __attribute__((noinline, noclone)) void
36 f3 (void)
38 int i;
39 for (i = 0; i < N/2; ++i)
41 k[2*i] = a[2*i] < b[2*i] ? 51 : 12;
42 k[2*i+1] = a[2*i+1] > b[2*i+1] ? 51 : 12;
46 __attribute__((noinline, noclone)) void
47 f4 (void)
49 int i;
50 for (i = 0; i < N/2; ++i)
52 int d0 = d[2*i], e0 = e[2*i];
53 int d1 = d[2*i+1], e1 = e[2*i+1];
54 f[2*i] = a[2*i] >= b[2*i] ? d0 : e0;
55 f[2*i+1] = a[2*i+1] >= b[2*i+1] ? d1 : e1;
59 int
60 main ()
62 int i;
64 check_vect ();
66 for (i = 0; i < N; i++)
68 switch (i % 9)
70 case 0: asm (""); a[i] = - i - 1; b[i] = i + 1; break;
71 case 1: a[i] = 0; b[i] = 0; break;
72 case 2: a[i] = i + 1; b[i] = - i - 1; break;
73 case 3: a[i] = i; b[i] = i + 7; break;
74 case 4: a[i] = i; b[i] = i; break;
75 case 5: a[i] = i + 16; b[i] = i + 3; break;
76 case 6: a[i] = - i - 5; b[i] = - i; break;
77 case 7: a[i] = - i; b[i] = - i; break;
78 case 8: a[i] = - i; b[i] = - i - 7; break;
80 d[i] = i;
81 e[i] = 2 * i;
84 f1 ();
85 for (i = 0; i < N; i++)
86 if (k[i] != ((i % 3) == 0 ? 17 : 0))
87 abort ();
89 f2 ();
90 for (i = 0; i < N; i++)
92 switch (i % 9)
94 case 0:
95 case 6:
96 if (k[i] != ((i/9 % 2) == 0 ? 0 : 7))
97 abort ();
98 break;
99 case 1:
100 case 5:
101 case 7:
102 if (k[i] != ((i/9 % 2) == 0 ? 4 : 24))
103 abort ();
104 break;
105 case 2:
106 case 4:
107 case 8:
108 if (k[i] != ((i/9 % 2) == 0 ? 24 : 4))
109 abort ();
110 break;
111 case 3:
112 if (k[i] != ((i/9 % 2) == 0 ? 7 : 0))
113 abort ();
114 break;
118 f3 ();
120 f4 ();
121 for (i = 0; i < N; i++)
122 if (f[i] != ((i % 3) == 0 ? e[i] : d[i]))
123 abort ();
125 return 0;
128 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" } } */