Skip to content

Commit 9c4ef23

Browse files
committed
[InstCombine] Test foldSelectICmpAnd with extra uses. (NFC)
1 parent 81c85ea commit 9c4ef23

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

llvm/test/Transforms/InstCombine/select-icmp-and.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,22 @@ define i32 @test15e(i32 %X) {
372372
ret i32 %t3
373373
}
374374

375+
;; (a & 128) ? 256 : 0
376+
define i32 @test15e_extra_use(i32 %X) {
377+
; CHECK-LABEL: @test15e_extra_use(
378+
; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 128
379+
; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
380+
; CHECK-NEXT: [[T3:%.*]] = shl nuw nsw i32 [[T1]], 1
381+
; CHECK-NEXT: call void @use1(i1 [[T2]])
382+
; CHECK-NEXT: ret i32 [[T3]]
383+
;
384+
%t1 = and i32 %X, 128
385+
%t2 = icmp ne i32 %t1, 0
386+
%t3 = select i1 %t2, i32 256, i32 0
387+
call void @use1(i1 %t2)
388+
ret i32 %t3
389+
}
390+
375391
;; (a & 128) ? 0 : 256
376392
define i32 @test15f(i32 %X) {
377393
; CHECK-LABEL: @test15f(
@@ -386,6 +402,23 @@ define i32 @test15f(i32 %X) {
386402
ret i32 %t3
387403
}
388404

405+
;; (a & 128) ? 0 : 256
406+
define i32 @test15f_extra_use(i32 %X) {
407+
; CHECK-LABEL: @test15f_extra_use(
408+
; CHECK-NEXT: [[T1:%.*]] = and i32 [[X:%.*]], 128
409+
; CHECK-NEXT: [[T2:%.*]] = icmp ne i32 [[T1]], 0
410+
; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i32 [[T1]], 1
411+
; CHECK-NEXT: [[T3:%.*]] = xor i32 [[TMP1]], 256
412+
; CHECK-NEXT: call void @use1(i1 [[T2]])
413+
; CHECK-NEXT: ret i32 [[T3]]
414+
;
415+
%t1 = and i32 %X, 128
416+
%t2 = icmp ne i32 %t1, 0
417+
%t3 = select i1 %t2, i32 0, i32 256
418+
call void @use1(i1 %t2)
419+
ret i32 %t3
420+
}
421+
389422
;; (a & 8) ? -1 : -9
390423
define i32 @test15g(i32 %X) {
391424
; CHECK-LABEL: @test15g(

0 commit comments

Comments
 (0)