[llvm] a632364 - [InstCombine] Add test for SimplifyDemanded context (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 03:22:17 PDT 2024


Author: Nikita Popov
Date: 2024-07-01T12:21:57+02:00
New Revision: a632364bceacef75610ffd8c8ed0fd4d76514ce7

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

LOG: [InstCombine] Add test for SimplifyDemanded context (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/known-bits.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/known-bits.ll b/llvm/test/Transforms/InstCombine/known-bits.ll
index 41b16f3333c1c..dafc37db0086e 100644
--- a/llvm/test/Transforms/InstCombine/known-bits.ll
+++ b/llvm/test/Transforms/InstCombine/known-bits.ll
@@ -2008,5 +2008,25 @@ if.else:
   ret i8 %other
 }
 
+define i8 @simplifydemanded_context(i8 %x, i8 %y) {
+; CHECK-LABEL: @simplifydemanded_context(
+; CHECK-NEXT:    [[AND1:%.*]] = and i8 [[X:%.*]], 1
+; CHECK-NEXT:    call void @dummy()
+; CHECK-NEXT:    [[X_LOBITS:%.*]] = and i8 [[X]], 3
+; CHECK-NEXT:    [[PRECOND:%.*]] = icmp eq i8 [[X_LOBITS]], 0
+; CHECK-NEXT:    call void @llvm.assume(i1 [[PRECOND]])
+; CHECK-NEXT:    [[AND2:%.*]] = and i8 [[AND1]], [[Y:%.*]]
+; CHECK-NEXT:    ret i8 [[AND2]]
+;
+  %and1 = and i8 %x, 1
+  call void @dummy() ; may unwind
+  %x.lobits = and i8 %x, 3
+  %precond = icmp eq i8 %x.lobits, 0
+  call void @llvm.assume(i1 %precond)
+  %and2 = and i8 %and1, %y
+  ret i8 %and2
+}
+
+declare void @dummy()
 declare void @use(i1)
 declare void @sink(i8)


        


More information about the llvm-commits mailing list