[llvm] 8cff391 - [NFC][InstSimplify] Add one more test for unneeded 'and'
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 20 14:33:40 PDT 2021
Author: Roman Lebedev
Date: 2021-04-21T00:31:46+03:00
New Revision: 8cff391995a91e851224b3aa428621c0ea89de18
URL: https://github.com/llvm/llvm-project/commit/8cff391995a91e851224b3aa428621c0ea89de18
DIFF: https://github.com/llvm/llvm-project/commit/8cff391995a91e851224b3aa428621c0ea89de18.diff
LOG: [NFC][InstSimplify] Add one more test for unneeded 'and'
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 2e364a789675c..ee94d2f7720ec 100644
--- a/llvm/test/Transforms/InstSimplify/AndOrXor.ll
+++ b/llvm/test/Transforms/InstSimplify/AndOrXor.ll
@@ -1186,3 +1186,29 @@ define i8 @xor_add_sub_wrong_op(i8 %x) {
%r = xor i8 %a, %s
ret i8 %r
}
+
+; `and` isn't needed if it doesn't actually change any bits.
+define i8 @noop_and_t0(i8 %x) {
+; CHECK-LABEL: @noop_and_t0(
+; CHECK-NEXT: [[A:%.*]] = shl i8 [[X:%.*]], 3
+; CHECK-NEXT: [[B:%.*]] = lshr i8 [[A]], 2
+; CHECK-NEXT: [[R:%.*]] = and i8 [[B]], 62
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %a = shl i8 %x, 3
+ %b = lshr i8 %a, 2
+ %r = and i8 %b, 62
+ ret i8 %r
+}
+define i8 @noop_and_t1(i8 %x) {
+; CHECK-LABEL: @noop_and_t1(
+; CHECK-NEXT: [[A:%.*]] = shl i8 [[X:%.*]], 3
+; CHECK-NEXT: [[B:%.*]] = lshr i8 [[A]], 2
+; CHECK-NEXT: [[R:%.*]] = and i8 [[B]], 126
+; CHECK-NEXT: ret i8 [[R]]
+;
+ %a = shl i8 %x, 3
+ %b = lshr i8 %a, 2
+ %r = and i8 %b, 126
+ ret i8 %r
+}
More information about the llvm-commits
mailing list