1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -slp-vectorizer -mtriple=x86_64-- -S | FileCheck %s
3 ; RUN: opt < %s -slp-vectorizer -mtriple=x86_64-- -mattr=avx512vl -S | FileCheck %s
7 define i1 @logical_and_icmp(<4 x i32> %x) {
8 ; CHECK-LABEL: @logical_and_icmp(
9 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[X:%.*]], zeroinitializer
10 ; CHECK-NEXT: [[TMP2:%.*]] = freeze <4 x i1> [[TMP1]]
11 ; CHECK-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP2]])
12 ; CHECK-NEXT: ret i1 [[TMP3]]
14 %x0 = extractelement <4 x i32> %x, i32 0
15 %x1 = extractelement <4 x i32> %x, i32 1
16 %x2 = extractelement <4 x i32> %x, i32 2
17 %x3 = extractelement <4 x i32> %x, i32 3
18 %c0 = icmp slt i32 %x0, 0
19 %c1 = icmp slt i32 %x1, 0
20 %c2 = icmp slt i32 %x2, 0
21 %c3 = icmp slt i32 %x3, 0
22 %s1 = select i1 %c0, i1 %c1, i1 false
23 %s2 = select i1 %s1, i1 %c2, i1 false
24 %s3 = select i1 %s2, i1 %c3, i1 false
28 define i1 @logical_or_icmp(<4 x i32> %x, <4 x i32> %y) {
29 ; CHECK-LABEL: @logical_or_icmp(
30 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt <4 x i32> [[X:%.*]], [[Y:%.*]]
31 ; CHECK-NEXT: [[TMP2:%.*]] = freeze <4 x i1> [[TMP1]]
32 ; CHECK-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP2]])
33 ; CHECK-NEXT: ret i1 [[TMP3]]
35 %x0 = extractelement <4 x i32> %x, i32 0
36 %x1 = extractelement <4 x i32> %x, i32 1
37 %x2 = extractelement <4 x i32> %x, i32 2
38 %x3 = extractelement <4 x i32> %x, i32 3
39 %y0 = extractelement <4 x i32> %y, i32 0
40 %y1 = extractelement <4 x i32> %y, i32 1
41 %y2 = extractelement <4 x i32> %y, i32 2
42 %y3 = extractelement <4 x i32> %y, i32 3
43 %c0 = icmp slt i32 %x0, %y0
44 %c1 = icmp slt i32 %x1, %y1
45 %c2 = icmp slt i32 %x2, %y2
46 %c3 = icmp slt i32 %x3, %y3
47 %s1 = select i1 %c0, i1 true, i1 %c1
48 %s2 = select i1 %s1, i1 true, i1 %c2
49 %s3 = select i1 %s2, i1 true, i1 %c3
53 define i1 @logical_and_fcmp(<4 x float> %x) {
54 ; CHECK-LABEL: @logical_and_fcmp(
55 ; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt <4 x float> [[X:%.*]], zeroinitializer
56 ; CHECK-NEXT: [[TMP2:%.*]] = freeze <4 x i1> [[TMP1]]
57 ; CHECK-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP2]])
58 ; CHECK-NEXT: ret i1 [[TMP3]]
60 %x0 = extractelement <4 x float> %x, i32 0
61 %x1 = extractelement <4 x float> %x, i32 1
62 %x2 = extractelement <4 x float> %x, i32 2
63 %x3 = extractelement <4 x float> %x, i32 3
64 %c0 = fcmp olt float %x0, 0.0
65 %c1 = fcmp olt float %x1, 0.0
66 %c2 = fcmp olt float %x2, 0.0
67 %c3 = fcmp olt float %x3, 0.0
68 %s1 = select i1 %c0, i1 %c1, i1 false
69 %s2 = select i1 %s1, i1 %c2, i1 false
70 %s3 = select i1 %s2, i1 %c3, i1 false
74 define i1 @logical_or_fcmp(<4 x float> %x) {
75 ; CHECK-LABEL: @logical_or_fcmp(
76 ; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt <4 x float> [[X:%.*]], zeroinitializer
77 ; CHECK-NEXT: [[TMP2:%.*]] = freeze <4 x i1> [[TMP1]]
78 ; CHECK-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP2]])
79 ; CHECK-NEXT: ret i1 [[TMP3]]
81 %x0 = extractelement <4 x float> %x, i32 0
82 %x1 = extractelement <4 x float> %x, i32 1
83 %x2 = extractelement <4 x float> %x, i32 2
84 %x3 = extractelement <4 x float> %x, i32 3
85 %c0 = fcmp olt float %x0, 0.0
86 %c1 = fcmp olt float %x1, 0.0
87 %c2 = fcmp olt float %x2, 0.0
88 %c3 = fcmp olt float %x3, 0.0
89 %s1 = select i1 %c0, i1 true, i1 %c1
90 %s2 = select i1 %s1, i1 true, i1 %c2
91 %s3 = select i1 %s2, i1 true, i1 %c3
95 define i1 @logical_and_icmp_diff_preds(<4 x i32> %x) {
96 ; CHECK-LABEL: @logical_and_icmp_diff_preds(
97 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
98 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
99 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
100 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
101 ; CHECK-NEXT: [[C0:%.*]] = icmp ult i32 [[X0]], 0
102 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 0
103 ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[X2]], 0
104 ; CHECK-NEXT: [[C3:%.*]] = icmp slt i32 [[X3]], 0
105 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
106 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
107 ; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
108 ; CHECK-NEXT: ret i1 [[S3]]
110 %x0 = extractelement <4 x i32> %x, i32 0
111 %x1 = extractelement <4 x i32> %x, i32 1
112 %x2 = extractelement <4 x i32> %x, i32 2
113 %x3 = extractelement <4 x i32> %x, i32 3
114 %c0 = icmp ult i32 %x0, 0
115 %c1 = icmp slt i32 %x1, 0
116 %c2 = icmp sgt i32 %x2, 0
117 %c3 = icmp slt i32 %x3, 0
118 %s1 = select i1 %c0, i1 %c1, i1 false
119 %s2 = select i1 %s1, i1 %c2, i1 false
120 %s3 = select i1 %s2, i1 %c3, i1 false
124 define i1 @logical_and_icmp_diff_const(<4 x i32> %x) {
125 ; CHECK-LABEL: @logical_and_icmp_diff_const(
126 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt <4 x i32> [[X:%.*]], <i32 0, i32 1, i32 2, i32 3>
127 ; CHECK-NEXT: [[TMP2:%.*]] = freeze <4 x i1> [[TMP1]]
128 ; CHECK-NEXT: [[TMP3:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP2]])
129 ; CHECK-NEXT: ret i1 [[TMP3]]
131 %x0 = extractelement <4 x i32> %x, i32 0
132 %x1 = extractelement <4 x i32> %x, i32 1
133 %x2 = extractelement <4 x i32> %x, i32 2
134 %x3 = extractelement <4 x i32> %x, i32 3
135 %c0 = icmp sgt i32 %x0, 0
136 %c1 = icmp sgt i32 %x1, 1
137 %c2 = icmp sgt i32 %x2, 2
138 %c3 = icmp sgt i32 %x3, 3
139 %s1 = select i1 %c0, i1 %c1, i1 false
140 %s2 = select i1 %s1, i1 %c2, i1 false
141 %s3 = select i1 %s2, i1 %c3, i1 false
145 define i1 @mixed_logical_icmp(<4 x i32> %x) {
146 ; CHECK-LABEL: @mixed_logical_icmp(
147 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
148 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
149 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
150 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
151 ; CHECK-NEXT: [[C0:%.*]] = icmp sgt i32 [[X0]], 0
152 ; CHECK-NEXT: [[C1:%.*]] = icmp sgt i32 [[X1]], 0
153 ; CHECK-NEXT: [[C2:%.*]] = icmp sgt i32 [[X2]], 0
154 ; CHECK-NEXT: [[C3:%.*]] = icmp sgt i32 [[X3]], 0
155 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
156 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 true, i1 [[C2]]
157 ; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
158 ; CHECK-NEXT: ret i1 [[S3]]
160 %x0 = extractelement <4 x i32> %x, i32 0
161 %x1 = extractelement <4 x i32> %x, i32 1
162 %x2 = extractelement <4 x i32> %x, i32 2
163 %x3 = extractelement <4 x i32> %x, i32 3
164 %c0 = icmp sgt i32 %x0, 0
165 %c1 = icmp sgt i32 %x1, 0
166 %c2 = icmp sgt i32 %x2, 0
167 %c3 = icmp sgt i32 %x3, 0
168 %s1 = select i1 %c0, i1 %c1, i1 false
169 %s2 = select i1 %s1, i1 true, i1 %c2
170 %s3 = select i1 %s2, i1 %c3, i1 false
174 define i1 @logical_and_icmp_subvec(<4 x i32> %x) {
175 ; CHECK-LABEL: @logical_and_icmp_subvec(
176 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
177 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
178 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
179 ; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 0
180 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 0
181 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 0
182 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
183 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
184 ; CHECK-NEXT: ret i1 [[S2]]
186 %x0 = extractelement <4 x i32> %x, i32 0
187 %x1 = extractelement <4 x i32> %x, i32 1
188 %x2 = extractelement <4 x i32> %x, i32 2
189 %c0 = icmp slt i32 %x0, 0
190 %c1 = icmp slt i32 %x1, 0
191 %c2 = icmp slt i32 %x2, 0
192 %s1 = select i1 %c0, i1 %c1, i1 false
193 %s2 = select i1 %s1, i1 %c2, i1 false
197 ; TODO: This is better than all-scalar and still safe,
198 ; but we want this to be 2 reductions with glue
199 ; logic...or a wide reduction?
201 define i1 @logical_and_icmp_clamp(<4 x i32> %x) {
202 ; CHECK-LABEL: @logical_and_icmp_clamp(
203 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 3
204 ; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x i32> [[X]], i32 2
205 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i32> [[X]], i32 1
206 ; CHECK-NEXT: [[TMP4:%.*]] = extractelement <4 x i32> [[X]], i32 0
207 ; CHECK-NEXT: [[TMP5:%.*]] = icmp slt <4 x i32> [[X]], <i32 42, i32 42, i32 42, i32 42>
208 ; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[TMP4]], 17
209 ; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[TMP3]], 17
210 ; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[TMP2]], 17
211 ; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[TMP1]], 17
212 ; CHECK-NEXT: [[TMP6:%.*]] = freeze <4 x i1> [[TMP5]]
213 ; CHECK-NEXT: [[TMP7:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP6]])
214 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[TMP7]], i1 [[D0]], i1 false
215 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
216 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
217 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
218 ; CHECK-NEXT: ret i1 [[S7]]
220 %x0 = extractelement <4 x i32> %x, i32 0
221 %x1 = extractelement <4 x i32> %x, i32 1
222 %x2 = extractelement <4 x i32> %x, i32 2
223 %x3 = extractelement <4 x i32> %x, i32 3
224 %c0 = icmp slt i32 %x0, 42
225 %c1 = icmp slt i32 %x1, 42
226 %c2 = icmp slt i32 %x2, 42
227 %c3 = icmp slt i32 %x3, 42
228 %d0 = icmp sgt i32 %x0, 17
229 %d1 = icmp sgt i32 %x1, 17
230 %d2 = icmp sgt i32 %x2, 17
231 %d3 = icmp sgt i32 %x3, 17
232 %s1 = select i1 %c0, i1 %c1, i1 false
233 %s2 = select i1 %s1, i1 %c2, i1 false
234 %s3 = select i1 %s2, i1 %c3, i1 false
235 %s4 = select i1 %s3, i1 %d0, i1 false
236 %s5 = select i1 %s4, i1 %d1, i1 false
237 %s6 = select i1 %s5, i1 %d2, i1 false
238 %s7 = select i1 %s6, i1 %d3, i1 false
242 define i1 @logical_and_icmp_clamp_extra_use_cmp(<4 x i32> %x) {
243 ; CHECK-LABEL: @logical_and_icmp_clamp_extra_use_cmp(
244 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
245 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
246 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
247 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
248 ; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 42
249 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 42
250 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 42
251 ; CHECK-NEXT: call void @use1(i1 [[C2]])
252 ; CHECK-NEXT: [[C3:%.*]] = icmp slt i32 [[X3]], 42
253 ; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[X0]], 17
254 ; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[X1]], 17
255 ; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[X2]], 17
256 ; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[X3]], 17
257 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
258 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
259 ; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
260 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[S3]], i1 [[D0]], i1 false
261 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
262 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
263 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
264 ; CHECK-NEXT: ret i1 [[S7]]
266 %x0 = extractelement <4 x i32> %x, i32 0
267 %x1 = extractelement <4 x i32> %x, i32 1
268 %x2 = extractelement <4 x i32> %x, i32 2
269 %x3 = extractelement <4 x i32> %x, i32 3
270 %c0 = icmp slt i32 %x0, 42
271 %c1 = icmp slt i32 %x1, 42
272 %c2 = icmp slt i32 %x2, 42
273 call void @use1(i1 %c2)
274 %c3 = icmp slt i32 %x3, 42
275 %d0 = icmp sgt i32 %x0, 17
276 %d1 = icmp sgt i32 %x1, 17
277 %d2 = icmp sgt i32 %x2, 17
278 %d3 = icmp sgt i32 %x3, 17
279 %s1 = select i1 %c0, i1 %c1, i1 false
280 %s2 = select i1 %s1, i1 %c2, i1 false
281 %s3 = select i1 %s2, i1 %c3, i1 false
282 %s4 = select i1 %s3, i1 %d0, i1 false
283 %s5 = select i1 %s4, i1 %d1, i1 false
284 %s6 = select i1 %s5, i1 %d2, i1 false
285 %s7 = select i1 %s6, i1 %d3, i1 false
289 define i1 @logical_and_icmp_clamp_extra_use_select(<4 x i32> %x) {
290 ; CHECK-LABEL: @logical_and_icmp_clamp_extra_use_select(
291 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
292 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
293 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
294 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
295 ; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 42
296 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 42
297 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 42
298 ; CHECK-NEXT: [[C3:%.*]] = icmp slt i32 [[X3]], 42
299 ; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[X0]], 17
300 ; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[X1]], 17
301 ; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[X2]], 17
302 ; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[X3]], 17
303 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
304 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
305 ; CHECK-NEXT: call void @use1(i1 [[S2]])
306 ; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
307 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[S3]], i1 [[D0]], i1 false
308 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
309 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
310 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
311 ; CHECK-NEXT: ret i1 [[S7]]
313 %x0 = extractelement <4 x i32> %x, i32 0
314 %x1 = extractelement <4 x i32> %x, i32 1
315 %x2 = extractelement <4 x i32> %x, i32 2
316 %x3 = extractelement <4 x i32> %x, i32 3
317 %c0 = icmp slt i32 %x0, 42
318 %c1 = icmp slt i32 %x1, 42
319 %c2 = icmp slt i32 %x2, 42
320 %c3 = icmp slt i32 %x3, 42
321 %d0 = icmp sgt i32 %x0, 17
322 %d1 = icmp sgt i32 %x1, 17
323 %d2 = icmp sgt i32 %x2, 17
324 %d3 = icmp sgt i32 %x3, 17
325 %s1 = select i1 %c0, i1 %c1, i1 false
326 %s2 = select i1 %s1, i1 %c2, i1 false
327 call void @use1(i1 %s2)
328 %s3 = select i1 %s2, i1 %c3, i1 false
329 %s4 = select i1 %s3, i1 %d0, i1 false
330 %s5 = select i1 %s4, i1 %d1, i1 false
331 %s6 = select i1 %s5, i1 %d2, i1 false
332 %s7 = select i1 %s6, i1 %d3, i1 false
336 define i1 @logical_and_icmp_clamp_v8i32(<8 x i32> %x, <8 x i32> %y) {
337 ; CHECK-LABEL: @logical_and_icmp_clamp_v8i32(
338 ; CHECK-NEXT: [[X0:%.*]] = extractelement <8 x i32> [[X:%.*]], i32 0
339 ; CHECK-NEXT: [[X1:%.*]] = extractelement <8 x i32> [[X]], i32 1
340 ; CHECK-NEXT: [[X2:%.*]] = extractelement <8 x i32> [[X]], i32 2
341 ; CHECK-NEXT: [[X3:%.*]] = extractelement <8 x i32> [[X]], i32 3
342 ; CHECK-NEXT: [[Y0:%.*]] = extractelement <8 x i32> [[Y:%.*]], i32 0
343 ; CHECK-NEXT: [[Y1:%.*]] = extractelement <8 x i32> [[Y]], i32 1
344 ; CHECK-NEXT: [[Y2:%.*]] = extractelement <8 x i32> [[Y]], i32 2
345 ; CHECK-NEXT: [[Y3:%.*]] = extractelement <8 x i32> [[Y]], i32 3
346 ; CHECK-NEXT: [[TMP1:%.*]] = insertelement <4 x i32> poison, i32 [[X0]], i32 0
347 ; CHECK-NEXT: [[TMP2:%.*]] = insertelement <4 x i32> [[TMP1]], i32 [[X1]], i32 1
348 ; CHECK-NEXT: [[TMP3:%.*]] = insertelement <4 x i32> [[TMP2]], i32 [[X2]], i32 2
349 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <4 x i32> [[TMP3]], i32 [[X3]], i32 3
350 ; CHECK-NEXT: [[TMP5:%.*]] = icmp slt <4 x i32> [[TMP4]], <i32 42, i32 42, i32 42, i32 42>
351 ; CHECK-NEXT: [[D0:%.*]] = icmp slt i32 [[X0]], [[Y0]]
352 ; CHECK-NEXT: [[D1:%.*]] = icmp slt i32 [[X1]], [[Y1]]
353 ; CHECK-NEXT: [[D2:%.*]] = icmp slt i32 [[X2]], [[Y2]]
354 ; CHECK-NEXT: [[D3:%.*]] = icmp slt i32 [[X3]], [[Y3]]
355 ; CHECK-NEXT: [[TMP6:%.*]] = freeze <4 x i1> [[TMP5]]
356 ; CHECK-NEXT: [[TMP7:%.*]] = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> [[TMP6]])
357 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[TMP7]], i1 [[D0]], i1 false
358 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
359 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
360 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
361 ; CHECK-NEXT: ret i1 [[S7]]
363 %x0 = extractelement <8 x i32> %x, i32 0
364 %x1 = extractelement <8 x i32> %x, i32 1
365 %x2 = extractelement <8 x i32> %x, i32 2
366 %x3 = extractelement <8 x i32> %x, i32 3
367 %y0 = extractelement <8 x i32> %y, i32 0
368 %y1 = extractelement <8 x i32> %y, i32 1
369 %y2 = extractelement <8 x i32> %y, i32 2
370 %y3 = extractelement <8 x i32> %y, i32 3
371 %c0 = icmp slt i32 %x0, 42
372 %c1 = icmp slt i32 %x1, 42
373 %c2 = icmp slt i32 %x2, 42
374 %c3 = icmp slt i32 %x3, 42
375 %d0 = icmp slt i32 %x0, %y0
376 %d1 = icmp slt i32 %x1, %y1
377 %d2 = icmp slt i32 %x2, %y2
378 %d3 = icmp slt i32 %x3, %y3
379 %s1 = select i1 %c0, i1 %c1, i1 false
380 %s2 = select i1 %s1, i1 %c2, i1 false
381 %s3 = select i1 %s2, i1 %c3, i1 false
382 %s4 = select i1 %s3, i1 %d0, i1 false
383 %s5 = select i1 %s4, i1 %d1, i1 false
384 %s6 = select i1 %s5, i1 %d2, i1 false
385 %s7 = select i1 %s6, i1 %d3, i1 false
389 define i1 @logical_and_icmp_clamp_partial(<4 x i32> %x) {
390 ; CHECK-LABEL: @logical_and_icmp_clamp_partial(
391 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
392 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
393 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
394 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
395 ; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 42
396 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 42
397 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 42
398 ; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[X0]], 17
399 ; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[X1]], 17
400 ; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[X2]], 17
401 ; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[X3]], 17
402 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
403 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
404 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[S2]], i1 [[D0]], i1 false
405 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
406 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
407 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
408 ; CHECK-NEXT: ret i1 [[S7]]
410 %x0 = extractelement <4 x i32> %x, i32 0
411 %x1 = extractelement <4 x i32> %x, i32 1
412 %x2 = extractelement <4 x i32> %x, i32 2
413 %x3 = extractelement <4 x i32> %x, i32 3
414 %c0 = icmp slt i32 %x0, 42
415 %c1 = icmp slt i32 %x1, 42
416 %c2 = icmp slt i32 %x2, 42
417 ; remove an element from the previous test
418 %d0 = icmp sgt i32 %x0, 17
419 %d1 = icmp sgt i32 %x1, 17
420 %d2 = icmp sgt i32 %x2, 17
421 %d3 = icmp sgt i32 %x3, 17
422 %s1 = select i1 %c0, i1 %c1, i1 false
423 %s2 = select i1 %s1, i1 %c2, i1 false
424 ; remove an element from the previous test
425 %s4 = select i1 %s2, i1 %d0, i1 false
426 %s5 = select i1 %s4, i1 %d1, i1 false
427 %s6 = select i1 %s5, i1 %d2, i1 false
428 %s7 = select i1 %s6, i1 %d3, i1 false
432 define i1 @logical_and_icmp_clamp_pred_diff(<4 x i32> %x) {
433 ; CHECK-LABEL: @logical_and_icmp_clamp_pred_diff(
434 ; CHECK-NEXT: [[X0:%.*]] = extractelement <4 x i32> [[X:%.*]], i32 0
435 ; CHECK-NEXT: [[X1:%.*]] = extractelement <4 x i32> [[X]], i32 1
436 ; CHECK-NEXT: [[X2:%.*]] = extractelement <4 x i32> [[X]], i32 2
437 ; CHECK-NEXT: [[X3:%.*]] = extractelement <4 x i32> [[X]], i32 3
438 ; CHECK-NEXT: [[C0:%.*]] = icmp slt i32 [[X0]], 42
439 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[X1]], 42
440 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[X2]], 42
441 ; CHECK-NEXT: [[C3:%.*]] = icmp ult i32 [[X3]], 42
442 ; CHECK-NEXT: [[D0:%.*]] = icmp sgt i32 [[X0]], 17
443 ; CHECK-NEXT: [[D1:%.*]] = icmp sgt i32 [[X1]], 17
444 ; CHECK-NEXT: [[D2:%.*]] = icmp sgt i32 [[X2]], 17
445 ; CHECK-NEXT: [[D3:%.*]] = icmp sgt i32 [[X3]], 17
446 ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C0]], i1 [[C1]], i1 false
447 ; CHECK-NEXT: [[S2:%.*]] = select i1 [[S1]], i1 [[C2]], i1 false
448 ; CHECK-NEXT: [[S3:%.*]] = select i1 [[S2]], i1 [[C3]], i1 false
449 ; CHECK-NEXT: [[S4:%.*]] = select i1 [[S3]], i1 [[D0]], i1 false
450 ; CHECK-NEXT: [[S5:%.*]] = select i1 [[S4]], i1 [[D1]], i1 false
451 ; CHECK-NEXT: [[S6:%.*]] = select i1 [[S5]], i1 [[D2]], i1 false
452 ; CHECK-NEXT: [[S7:%.*]] = select i1 [[S6]], i1 [[D3]], i1 false
453 ; CHECK-NEXT: ret i1 [[S7]]
455 %x0 = extractelement <4 x i32> %x, i32 0
456 %x1 = extractelement <4 x i32> %x, i32 1
457 %x2 = extractelement <4 x i32> %x, i32 2
458 %x3 = extractelement <4 x i32> %x, i32 3
459 %c0 = icmp slt i32 %x0, 42
460 %c1 = icmp slt i32 %x1, 42
461 %c2 = icmp slt i32 %x2, 42
462 %c3 = icmp ult i32 %x3, 42 ; predicate changed
463 %d0 = icmp sgt i32 %x0, 17
464 %d1 = icmp sgt i32 %x1, 17
465 %d2 = icmp sgt i32 %x2, 17
466 %d3 = icmp sgt i32 %x3, 17
467 %s1 = select i1 %c0, i1 %c1, i1 false
468 %s2 = select i1 %s1, i1 %c2, i1 false
469 %s3 = select i1 %s2, i1 %c3, i1 false
470 %s4 = select i1 %s3, i1 %d0, i1 false
471 %s5 = select i1 %s4, i1 %d1, i1 false
472 %s6 = select i1 %s5, i1 %d2, i1 false
473 %s7 = select i1 %s6, i1 %d3, i1 false