1 /* { dg-require-effective-target vect_int } */
2 /* { dg-additional-options "-O3" } */
3 #include <limits.h>
4
5 unsigned __attribute__ ((noinline))
6 foo (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
7 {
8 while (n < ++l)
9 *a++ = *b++ + 1;
10 return l;
11 }
12
13 unsigned __attribute__ ((noinline))
14 foo_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned)
15 {
16 while (UINT_MAX - 64 < ++l)
17 *a++ = *b++ + 1;
18 return l;
19 }
20
21 unsigned __attribute__ ((noinline))
22 foo_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
23 {
24 l = UINT_MAX - 32;
25 while (n < ++l)
26 *a++ = *b++ + 1;
27 return l;
28 }
29
30 unsigned __attribute__ ((noinline))
31 foo_3 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
32 {
33 while (n <= ++l)
34 *a++ = *b++ + 1;
35 return l;
36 }
37
38 unsigned __attribute__ ((noinline))
39 foo_4 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
40 { // infininate
41 while (0 <= ++l)
42 *a++ = *b++ + 1;
43 return l;
44 }
45
46 unsigned __attribute__ ((noinline))
47 foo_5 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
48 {
49 //no loop
50 l = UINT_MAX;
51 while (n < ++l)
52 *a++ = *b++ + 1;
53 return l;
54 }
55
56 unsigned __attribute__ ((noinline))
57 bar (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
58 {
59 while (--l < n)
60 *a++ = *b++ + 1;
61 return l;
62 }
63
64 unsigned __attribute__ ((noinline))
65 bar_1 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned)
66 {
67 while (--l < 64)
68 *a++ = *b++ + 1;
69 return l;
70 }
71
72 unsigned __attribute__ ((noinline))
73 bar_2 (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n)
74 {
75 l = 32;
76 while (--l < n)
77 *a++ = *b++ + 1;
78 return l;
79 }
80
81
82 int a[3200], b[3200];
83 int fail;
84
85 int
86 main ()
87 {
88 unsigned l, n;
89 unsigned res;
90 /* l > n*/
91 n = UINT_MAX - 64;
92 l = n + 32;
93 res = foo (a, b, l, n);
94 if (res != 0)
95 fail++;
96
97 l = n;
98 res = foo (a, b, l, n);
99 if (res != 0)
100 fail++;
101
102 l = n - 1;
103 res = foo (a, b, l, n);
104 if (res != l + 1)
105 fail++;
106
107 l = n - 32;
108 res = foo (a, b, l, n);
109 if (res != l + 1)
110 fail++;
111
112 l = UINT_MAX;
113 res = foo (a, b, l, n);
114 if (res != 0)
115 fail++;
116
117 l = n + 32;
118 res = foo_1 (a, b, l, n);
119 if (res != 0)
120 fail++;
121
122 l = n + 32;
123 res = foo_2 (a, b, l, n);
124 if (res != 0)
125 fail++;
126
127 l = n;
128 res = foo_3 (a, b, l, n);
129 if (res != 0)
130 fail++;
131
132 l = n - 1;
133 res = foo_3 (a, b, l, n);
134 if (res != 0)
135 fail++;
136
137 l = n - 2;
138 res = foo_3 (a, b, l, n);
139 if (res != l + 1)
140 fail++;
141
142 res = foo_5 (a, b, l, n);
143 if (res != 0)
144 fail++;
145
146 n = 64;
147 l = n - 32;
148 res = bar (a, b, l, n);
149 res++;
150 if (res != 0)
151 fail++;
152
153 l = n;
154 res = bar (a, b, l, n);
155 res++;
156 if (res != 0)
157 fail++;
158
159 l = n + 1;
160 res = bar (a, b, l, n);
161 res++;
162 if (res != l)
163 fail++;
164
165 l = 0;
166 res = bar (a, b, l, n);
167 res++;
168 if (res != l)
169 fail++;
170
171 l = 32;
172 res = bar_1 (a, b, l, n);
173 res++;
174 if (res != 0)
175 fail++;
176
177 res = bar_1 (a, b, l, n);
178 res++;
179 if (res != 0)
180 fail++;
181
182 if (fail)
183 __builtin_abort ();
184 return 0;
185 }
186
187 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 7 "vect" } } */