llvm.org GIT mirror llvm / 7cf515b
[SLP][X86] Add tests showing failure to commute icmp/fcmp by swapping predicate By swapping icmp/fcmp predicates we can commute their operands to improve vectorization git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357204 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 7 months ago
1 changed file(s) with 196 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
196196 %r = sext <4 x i1> %d3 to <4 x i32>
197197 ret <4 x i32> %r
198198 }
199
200 ;
201 ; Check that we can commute operands by swapping the predicate.
202 ;
203
204 define <4 x i32> @icmp_sgt_slt_v4i32(<4 x i32> %a, i32* %b) {
205 ; CHECK-LABEL: @icmp_sgt_slt_v4i32(
206 ; CHECK-NEXT: [[A0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 0
207 ; CHECK-NEXT: [[A1:%.*]] = extractelement <4 x i32> [[A]], i32 1
208 ; CHECK-NEXT: [[A2:%.*]] = extractelement <4 x i32> [[A]], i32 2
209 ; CHECK-NEXT: [[A3:%.*]] = extractelement <4 x i32> [[A]], i32 3
210 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
211 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
212 ; CHECK-NEXT: [[P3:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
213 ; CHECK-NEXT: [[B0:%.*]] = load i32, i32* [[B]], align 4
214 ; CHECK-NEXT: [[B1:%.*]] = load i32, i32* [[P1]], align 4
215 ; CHECK-NEXT: [[B2:%.*]] = load i32, i32* [[P2]], align 4
216 ; CHECK-NEXT: [[B3:%.*]] = load i32, i32* [[P3]], align 4
217 ; CHECK-NEXT: [[C0:%.*]] = icmp sgt i32 [[A0]], [[B0]]
218 ; CHECK-NEXT: [[C1:%.*]] = icmp slt i32 [[B1]], [[A1]]
219 ; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[B2]], [[A2]]
220 ; CHECK-NEXT: [[C3:%.*]] = icmp sgt i32 [[A3]], [[B3]]
221 ; CHECK-NEXT: [[D0:%.*]] = insertelement <4 x i1> undef, i1 [[C0]], i32 0
222 ; CHECK-NEXT: [[D1:%.*]] = insertelement <4 x i1> [[D0]], i1 [[C1]], i32 1
223 ; CHECK-NEXT: [[D2:%.*]] = insertelement <4 x i1> [[D1]], i1 [[C2]], i32 2
224 ; CHECK-NEXT: [[D3:%.*]] = insertelement <4 x i1> [[D2]], i1 [[C3]], i32 3
225 ; CHECK-NEXT: [[R:%.*]] = sext <4 x i1> [[D3]] to <4 x i32>
226 ; CHECK-NEXT: ret <4 x i32> [[R]]
227 ;
228 %a0 = extractelement <4 x i32> %a, i32 0
229 %a1 = extractelement <4 x i32> %a, i32 1
230 %a2 = extractelement <4 x i32> %a, i32 2
231 %a3 = extractelement <4 x i32> %a, i32 3
232 %p0 = getelementptr inbounds i32, i32* %b, i32 0
233 %p1 = getelementptr inbounds i32, i32* %b, i32 1
234 %p2 = getelementptr inbounds i32, i32* %b, i32 2
235 %p3 = getelementptr inbounds i32, i32* %b, i32 3
236 %b0 = load i32, i32* %p0, align 4
237 %b1 = load i32, i32* %p1, align 4
238 %b2 = load i32, i32* %p2, align 4
239 %b3 = load i32, i32* %p3, align 4
240 %c0 = icmp sgt i32 %a0, %b0
241 %c1 = icmp slt i32 %b1, %a1
242 %c2 = icmp slt i32 %b2, %a2
243 %c3 = icmp sgt i32 %a3, %b3
244 %d0 = insertelement <4 x i1> undef, i1 %c0, i32 0
245 %d1 = insertelement <4 x i1> %d0, i1 %c1, i32 1
246 %d2 = insertelement <4 x i1> %d1, i1 %c2, i32 2
247 %d3 = insertelement <4 x i1> %d2, i1 %c3, i32 3
248 %r = sext <4 x i1> %d3 to <4 x i32>
249 ret <4 x i32> %r
250 }
251
252 define <4 x i32> @icmp_uge_ule_v4i32(<4 x i32> %a, i32* %b) {
253 ; CHECK-LABEL: @icmp_uge_ule_v4i32(
254 ; CHECK-NEXT: [[A0:%.*]] = extractelement <4 x i32> [[A:%.*]], i32 0
255 ; CHECK-NEXT: [[A1:%.*]] = extractelement <4 x i32> [[A]], i32 1
256 ; CHECK-NEXT: [[A2:%.*]] = extractelement <4 x i32> [[A]], i32 2
257 ; CHECK-NEXT: [[A3:%.*]] = extractelement <4 x i32> [[A]], i32 3
258 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i32, i32* [[B:%.*]], i64 1
259 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 2
260 ; CHECK-NEXT: [[P3:%.*]] = getelementptr inbounds i32, i32* [[B]], i64 3
261 ; CHECK-NEXT: [[B0:%.*]] = load i32, i32* [[B]], align 4
262 ; CHECK-NEXT: [[B1:%.*]] = load i32, i32* [[P1]], align 4
263 ; CHECK-NEXT: [[B2:%.*]] = load i32, i32* [[P2]], align 4
264 ; CHECK-NEXT: [[B3:%.*]] = load i32, i32* [[P3]], align 4
265 ; CHECK-NEXT: [[C0:%.*]] = icmp uge i32 [[A0]], [[B0]]
266 ; CHECK-NEXT: [[C1:%.*]] = icmp ule i32 [[B1]], [[A1]]
267 ; CHECK-NEXT: [[C2:%.*]] = icmp ule i32 [[B2]], [[A2]]
268 ; CHECK-NEXT: [[C3:%.*]] = icmp uge i32 [[A3]], [[B3]]
269 ; CHECK-NEXT: [[D0:%.*]] = insertelement <4 x i1> undef, i1 [[C0]], i32 0
270 ; CHECK-NEXT: [[D1:%.*]] = insertelement <4 x i1> [[D0]], i1 [[C1]], i32 1
271 ; CHECK-NEXT: [[D2:%.*]] = insertelement <4 x i1> [[D1]], i1 [[C2]], i32 2
272 ; CHECK-NEXT: [[D3:%.*]] = insertelement <4 x i1> [[D2]], i1 [[C3]], i32 3
273 ; CHECK-NEXT: [[R:%.*]] = sext <4 x i1> [[D3]] to <4 x i32>
274 ; CHECK-NEXT: ret <4 x i32> [[R]]
275 ;
276 %a0 = extractelement <4 x i32> %a, i32 0
277 %a1 = extractelement <4 x i32> %a, i32 1
278 %a2 = extractelement <4 x i32> %a, i32 2
279 %a3 = extractelement <4 x i32> %a, i32 3
280 %p0 = getelementptr inbounds i32, i32* %b, i32 0
281 %p1 = getelementptr inbounds i32, i32* %b, i32 1
282 %p2 = getelementptr inbounds i32, i32* %b, i32 2
283 %p3 = getelementptr inbounds i32, i32* %b, i32 3
284 %b0 = load i32, i32* %p0, align 4
285 %b1 = load i32, i32* %p1, align 4
286 %b2 = load i32, i32* %p2, align 4
287 %b3 = load i32, i32* %p3, align 4
288 %c0 = icmp uge i32 %a0, %b0
289 %c1 = icmp ule i32 %b1, %a1
290 %c2 = icmp ule i32 %b2, %a2
291 %c3 = icmp uge i32 %a3, %b3
292 %d0 = insertelement <4 x i1> undef, i1 %c0, i32 0
293 %d1 = insertelement <4 x i1> %d0, i1 %c1, i32 1
294 %d2 = insertelement <4 x i1> %d1, i1 %c2, i32 2
295 %d3 = insertelement <4 x i1> %d2, i1 %c3, i32 3
296 %r = sext <4 x i1> %d3 to <4 x i32>
297 ret <4 x i32> %r
298 }
299
300 define <4 x i32> @fcmp_ogt_olt_v4i32(<4 x float> %a, float* %b) {
301 ; CHECK-LABEL: @fcmp_ogt_olt_v4i32(
302 ; CHECK-NEXT: [[A0:%.*]] = extractelement <4 x float> [[A:%.*]], i32 0
303 ; CHECK-NEXT: [[A1:%.*]] = extractelement <4 x float> [[A]], i32 1
304 ; CHECK-NEXT: [[A2:%.*]] = extractelement <4 x float> [[A]], i32 2
305 ; CHECK-NEXT: [[A3:%.*]] = extractelement <4 x float> [[A]], i32 3
306 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 1
307 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds float, float* [[B]], i64 2
308 ; CHECK-NEXT: [[P3:%.*]] = getelementptr inbounds float, float* [[B]], i64 3
309 ; CHECK-NEXT: [[B0:%.*]] = load float, float* [[B]], align 4
310 ; CHECK-NEXT: [[B1:%.*]] = load float, float* [[P1]], align 4
311 ; CHECK-NEXT: [[B2:%.*]] = load float, float* [[P2]], align 4
312 ; CHECK-NEXT: [[B3:%.*]] = load float, float* [[P3]], align 4
313 ; CHECK-NEXT: [[C0:%.*]] = fcmp ogt float [[A0]], [[B0]]
314 ; CHECK-NEXT: [[C1:%.*]] = fcmp olt float [[B1]], [[A1]]
315 ; CHECK-NEXT: [[C2:%.*]] = fcmp olt float [[B2]], [[A2]]
316 ; CHECK-NEXT: [[C3:%.*]] = fcmp ogt float [[A3]], [[B3]]
317 ; CHECK-NEXT: [[D0:%.*]] = insertelement <4 x i1> undef, i1 [[C0]], i32 0
318 ; CHECK-NEXT: [[D1:%.*]] = insertelement <4 x i1> [[D0]], i1 [[C1]], i32 1
319 ; CHECK-NEXT: [[D2:%.*]] = insertelement <4 x i1> [[D1]], i1 [[C2]], i32 2
320 ; CHECK-NEXT: [[D3:%.*]] = insertelement <4 x i1> [[D2]], i1 [[C3]], i32 3
321 ; CHECK-NEXT: [[R:%.*]] = sext <4 x i1> [[D3]] to <4 x i32>
322 ; CHECK-NEXT: ret <4 x i32> [[R]]
323 ;
324 %a0 = extractelement <4 x float> %a, i32 0
325 %a1 = extractelement <4 x float> %a, i32 1
326 %a2 = extractelement <4 x float> %a, i32 2
327 %a3 = extractelement <4 x float> %a, i32 3
328 %p0 = getelementptr inbounds float, float* %b, i32 0
329 %p1 = getelementptr inbounds float, float* %b, i32 1
330 %p2 = getelementptr inbounds float, float* %b, i32 2
331 %p3 = getelementptr inbounds float, float* %b, i32 3
332 %b0 = load float, float* %p0, align 4
333 %b1 = load float, float* %p1, align 4
334 %b2 = load float, float* %p2, align 4
335 %b3 = load float, float* %p3, align 4
336 %c0 = fcmp ogt float %a0, %b0
337 %c1 = fcmp olt float %b1, %a1
338 %c2 = fcmp olt float %b2, %a2
339 %c3 = fcmp ogt float %a3, %b3
340 %d0 = insertelement <4 x i1> undef, i1 %c0, i32 0
341 %d1 = insertelement <4 x i1> %d0, i1 %c1, i32 1
342 %d2 = insertelement <4 x i1> %d1, i1 %c2, i32 2
343 %d3 = insertelement <4 x i1> %d2, i1 %c3, i32 3
344 %r = sext <4 x i1> %d3 to <4 x i32>
345 ret <4 x i32> %r
346 }
347
348 define <4 x i32> @fcmp_ord_uno_v4i32(<4 x float> %a, float* %b) {
349 ; CHECK-LABEL: @fcmp_ord_uno_v4i32(
350 ; CHECK-NEXT: [[A0:%.*]] = extractelement <4 x float> [[A:%.*]], i32 0
351 ; CHECK-NEXT: [[A1:%.*]] = extractelement <4 x float> [[A]], i32 1
352 ; CHECK-NEXT: [[A2:%.*]] = extractelement <4 x float> [[A]], i32 2
353 ; CHECK-NEXT: [[A3:%.*]] = extractelement <4 x float> [[A]], i32 3
354 ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 1
355 ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds float, float* [[B]], i64 2
356 ; CHECK-NEXT: [[P3:%.*]] = getelementptr inbounds float, float* [[B]], i64 3
357 ; CHECK-NEXT: [[B0:%.*]] = load float, float* [[B]], align 4
358 ; CHECK-NEXT: [[B1:%.*]] = load float, float* [[P1]], align 4
359 ; CHECK-NEXT: [[B2:%.*]] = load float, float* [[P2]], align 4
360 ; CHECK-NEXT: [[B3:%.*]] = load float, float* [[P3]], align 4
361 ; CHECK-NEXT: [[C0:%.*]] = fcmp ord float [[A0]], [[B0]]
362 ; CHECK-NEXT: [[C1:%.*]] = fcmp uno float [[B1]], [[A1]]
363 ; CHECK-NEXT: [[C2:%.*]] = fcmp uno float [[B2]], [[A2]]
364 ; CHECK-NEXT: [[C3:%.*]] = fcmp ord float [[A3]], [[B3]]
365 ; CHECK-NEXT: [[D0:%.*]] = insertelement <4 x i1> undef, i1 [[C0]], i32 0
366 ; CHECK-NEXT: [[D1:%.*]] = insertelement <4 x i1> [[D0]], i1 [[C1]], i32 1
367 ; CHECK-NEXT: [[D2:%.*]] = insertelement <4 x i1> [[D1]], i1 [[C2]], i32 2
368 ; CHECK-NEXT: [[D3:%.*]] = insertelement <4 x i1> [[D2]], i1 [[C3]], i32 3
369 ; CHECK-NEXT: [[R:%.*]] = sext <4 x i1> [[D3]] to <4 x i32>
370 ; CHECK-NEXT: ret <4 x i32> [[R]]
371 ;
372 %a0 = extractelement <4 x float> %a, i32 0
373 %a1 = extractelement <4 x float> %a, i32 1
374 %a2 = extractelement <4 x float> %a, i32 2
375 %a3 = extractelement <4 x float> %a, i32 3
376 %p0 = getelementptr inbounds float, float* %b, i32 0
377 %p1 = getelementptr inbounds float, float* %b, i32 1
378 %p2 = getelementptr inbounds float, float* %b, i32 2
379 %p3 = getelementptr inbounds float, float* %b, i32 3
380 %b0 = load float, float* %p0, align 4
381 %b1 = load float, float* %p1, align 4
382 %b2 = load float, float* %p2, align 4
383 %b3 = load float, float* %p3, align 4
384 %c0 = fcmp ord float %a0, %b0
385 %c1 = fcmp uno float %b1, %a1
386 %c2 = fcmp uno float %b2, %a2
387 %c3 = fcmp ord float %a3, %b3
388 %d0 = insertelement <4 x i1> undef, i1 %c0, i32 0
389 %d1 = insertelement <4 x i1> %d0, i1 %c1, i32 1
390 %d2 = insertelement <4 x i1> %d1, i1 %c2, i32 2
391 %d3 = insertelement <4 x i1> %d2, i1 %c3, i32 3
392 %r = sext <4 x i1> %d3 to <4 x i32>
393 ret <4 x i32> %r
394 }