[llvm] 9c4ef23 - [InstCombine] Test foldSelectICmpAnd with extra uses. (NFC)

Andreas Jonson via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 16 05:07:12 PST 2025


Author: Andreas Jonson
Date: 2025-02-16T14:01:05+01:00
New Revision: 9c4ef23126728562b8717cf404bdbbdeea1aa72e

URL: https://github.com/llvm/llvm-project/commit/9c4ef23126728562b8717cf404bdbbdeea1aa72e
DIFF: https://github.com/llvm/llvm-project/commit/9c4ef23126728562b8717cf404bdbbdeea1aa72e.diff

LOG: [InstCombine] Test foldSelectICmpAnd with extra uses. (NFC)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/select-icmp-and.ll b/llvm/test/Transforms/InstCombine/select-icmp-and.ll
index 219a66c314a07..7c95fc125ce7b 100644
--- a/llvm/test/Transforms/InstCombine/select-icmp-and.ll
+++ b/llvm/test/Transforms/InstCombine/select-icmp-and.ll
@@ -372,6 +372,22 @@ define i32 @test15e(i32 %X) {
   ret i32 %t3
 }
 
+;; (a & 128) ? 256 : 0
+define i32 @test15e_extra_use(i32 %X) {
+; CHECK-LABEL: @test15e_extra_use(
+; CHECK-NEXT:    [[T1:%.*]] = and i32 [[X:%.*]], 128
+; CHECK-NEXT:    [[T2:%.*]] = icmp ne i32 [[T1]], 0
+; CHECK-NEXT:    [[T3:%.*]] = shl nuw nsw i32 [[T1]], 1
+; CHECK-NEXT:    call void @use1(i1 [[T2]])
+; CHECK-NEXT:    ret i32 [[T3]]
+;
+  %t1 = and i32 %X, 128
+  %t2 = icmp ne i32 %t1, 0
+  %t3 = select i1 %t2, i32 256, i32 0
+  call void @use1(i1 %t2)
+  ret i32 %t3
+}
+
 ;; (a & 128) ? 0 : 256
 define i32 @test15f(i32 %X) {
 ; CHECK-LABEL: @test15f(
@@ -386,6 +402,23 @@ define i32 @test15f(i32 %X) {
   ret i32 %t3
 }
 
+;; (a & 128) ? 0 : 256
+define i32 @test15f_extra_use(i32 %X) {
+; CHECK-LABEL: @test15f_extra_use(
+; CHECK-NEXT:    [[T1:%.*]] = and i32 [[X:%.*]], 128
+; CHECK-NEXT:    [[T2:%.*]] = icmp ne i32 [[T1]], 0
+; CHECK-NEXT:    [[TMP1:%.*]] = shl nuw nsw i32 [[T1]], 1
+; CHECK-NEXT:    [[T3:%.*]] = xor i32 [[TMP1]], 256
+; CHECK-NEXT:    call void @use1(i1 [[T2]])
+; CHECK-NEXT:    ret i32 [[T3]]
+;
+  %t1 = and i32 %X, 128
+  %t2 = icmp ne i32 %t1, 0
+  %t3 = select i1 %t2, i32 0, i32 256
+  call void @use1(i1 %t2)
+  ret i32 %t3
+}
+
 ;; (a & 8) ? -1 : -9
 define i32 @test15g(i32 %X) {
 ; CHECK-LABEL: @test15g(


        


More information about the llvm-commits mailing list