[llvm] a9fe69c - [InstSimplify] fix bug in matching or-with-not op (PR46083)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 3 10:44:45 PDT 2020
Author: Dorit Nuzman
Date: 2020-06-03T13:44:29-04:00
New Revision: a9fe69c359de653015c39e413e48630d069abe27
URL: https://github.com/llvm/llvm-project/commit/a9fe69c359de653015c39e413e48630d069abe27
DIFF: https://github.com/llvm/llvm-project/commit/a9fe69c359de653015c39e413e48630d069abe27.diff
LOG: [InstSimplify] fix bug in matching or-with-not op (PR46083)
Added:
Modified:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/or.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 45850e41f978..63f545306630 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2195,7 +2195,7 @@ static Value *SimplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
return Constant::getAllOnesValue(Op1->getType());
// A | ~(A & ?) = -1
- if (match(Op1, m_Not(m_c_And(m_Specific(Op1), m_Value()))))
+ if (match(Op1, m_Not(m_c_And(m_Specific(Op0), m_Value()))))
return Constant::getAllOnesValue(Op0->getType());
Value *A, *B;
diff --git a/llvm/test/Transforms/InstSimplify/or.ll b/llvm/test/Transforms/InstSimplify/or.ll
index 619c8eba554a..e4c4153d62b2 100644
--- a/llvm/test/Transforms/InstSimplify/or.ll
+++ b/llvm/test/Transforms/InstSimplify/or.ll
@@ -248,10 +248,7 @@ define <2 x i399> @test8_apint(<2 x i399> %V, <2 x i399> %M) {
define i1 @or_with_not_op_commute1(i1 %a, i1 %b) {
; CHECK-LABEL: @or_with_not_op_commute1(
-; CHECK-NEXT: [[AB:%.*]] = and i1 [[A:%.*]], [[B:%.*]]
-; CHECK-NEXT: [[NOT:%.*]] = xor i1 [[AB]], true
-; CHECK-NEXT: [[R:%.*]] = or i1 [[A]], [[NOT]]
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
;
%ab = and i1 %a, %b
%not = xor i1 %ab, -1
@@ -263,10 +260,7 @@ define i1 @or_with_not_op_commute1(i1 %a, i1 %b) {
define i8 @or_with_not_op_commute2(i8 %a, i8 %b) {
; CHECK-LABEL: @or_with_not_op_commute2(
-; CHECK-NEXT: [[AB:%.*]] = and i8 [[B:%.*]], [[A:%.*]]
-; CHECK-NEXT: [[NOT:%.*]] = xor i8 [[AB]], -1
-; CHECK-NEXT: [[R:%.*]] = or i8 [[A]], [[NOT]]
-; CHECK-NEXT: ret i8 [[R]]
+; CHECK-NEXT: ret i8 -1
;
%ab = and i8 %b, %a
%not = xor i8 %ab, -1
More information about the llvm-commits
mailing list