[llvm] 30bd90b - [InstSimplify] Add another and(x,c) case where the mask is redundant (and in fact can constant fold away)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 04:26:02 PDT 2022


Author: Simon Pilgrim
Date: 2022-08-16T12:25:50+01:00
New Revision: 30bd90b8cd3d4ef0ec52da908396e4951963d101

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

LOG: [InstSimplify] Add another and(x,c) case where the mask is redundant (and in fact can constant fold away)

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/AndOrXor.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/AndOrXor.ll b/llvm/test/Transforms/InstSimplify/AndOrXor.ll
index c5189464f3c6f..7f1fcfed0f394 100644
--- a/llvm/test/Transforms/InstSimplify/AndOrXor.ll
+++ b/llvm/test/Transforms/InstSimplify/AndOrXor.ll
@@ -1126,3 +1126,17 @@ define i8 @noop_and_t1(i8 %x) {
   %r = and i8 %b, 126
   ret i8 %r
 }
+
+; hidden simplifydemandedbits constant.
+define i8 @noop_and_t2(i8 %x) {
+; CHECK-LABEL: @noop_and_t2(
+; CHECK-NEXT:    [[A:%.*]] = and i8 [[X:%.*]], 2
+; CHECK-NEXT:    [[B:%.*]] = or i8 [[A]], 127
+; CHECK-NEXT:    [[C:%.*]] = and i8 [[B]], 62
+; CHECK-NEXT:    ret i8 [[C]]
+;
+  %a = and i8 %x, 2
+  %b = or i8 %a, 127
+  %c = and i8 %b, 62
+  ret i8 %c
+}


        


More information about the llvm-commits mailing list