Skip to content

Commit 73be428

Browse files
AZero13AlexisPerry
authored andcommitted
[InstCombine] Simplify commutative matchers (NFC) (llvm#96665)
1 parent 7652cb2 commit 73be428

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,7 @@ bool PolynomialMultiplyRecognize::matchLeftShift(SelectInst *SelI,
770770
// select +++ ? T : 0
771771

772772
Value *U = *SelI->user_begin();
773-
if (!match(U, m_Xor(m_Specific(SelI), m_Value(R))) &&
774-
!match(U, m_Xor(m_Value(R), m_Specific(SelI))))
773+
if (!match(U, m_c_Xor(m_Specific(SelI), m_Value(R))))
775774
return false;
776775
// Matched: xor (select +++ ? 0 : T), R
777776
// xor (select +++ ? T : 0), R
@@ -814,15 +813,13 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
814813
CmpInst::Predicate P;
815814
bool TrueIfZero;
816815

817-
if (match(CondV, m_ICmp(P, m_Value(C), m_Zero())) ||
818-
match(CondV, m_ICmp(P, m_Zero(), m_Value(C)))) {
816+
if (match(CondV, m_c_ICmp(P, m_Value(C), m_Zero()))) {
819817
if (P != CmpInst::ICMP_EQ && P != CmpInst::ICMP_NE)
820818
return false;
821819
// Matched: select C == 0 ? ... : ...
822820
// select C != 0 ? ... : ...
823821
TrueIfZero = (P == CmpInst::ICMP_EQ);
824-
} else if (match(CondV, m_ICmp(P, m_Value(C), m_One())) ||
825-
match(CondV, m_ICmp(P, m_One(), m_Value(C)))) {
822+
} else if (match(CondV, m_c_ICmp(P, m_Value(C), m_One()))) {
826823
if (P != CmpInst::ICMP_EQ && P != CmpInst::ICMP_NE)
827824
return false;
828825
// Matched: select C == 1 ? ... : ...
@@ -832,8 +829,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
832829
return false;
833830

834831
Value *X = nullptr;
835-
if (!match(C, m_And(m_Value(X), m_One())) &&
836-
!match(C, m_And(m_One(), m_Value(X))))
832+
if (!match(C, m_c_And(m_Value(X), m_One())))
837833
return false;
838834
// Matched: select (X & 1) == +++ ? ... : ...
839835
// select (X & 1) != +++ ? ... : ...
@@ -845,8 +841,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
845841
if (!match(TrueV, m_LShr(m_Value(R), m_One())))
846842
return false;
847843
// Matched: select +++ ? (R >> 1) : ...
848-
if (!match(FalseV, m_Xor(m_Specific(TrueV), m_Value(Q))) &&
849-
!match(FalseV, m_Xor(m_Value(Q), m_Specific(TrueV))))
844+
if (!match(FalseV, m_c_Xor(m_Specific(TrueV), m_Value(Q))))
850845
return false;
851846
// Matched: select +++ ? (R >> 1) : (R >> 1) ^ Q
852847
// with commuting ^.
@@ -856,8 +851,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
856851
if (!match(FalseV, m_LShr(m_Value(R), m_One())))
857852
return false;
858853
// Matched: select +++ ? ... : (R >> 1)
859-
if (!match(TrueV, m_Xor(m_Specific(FalseV), m_Value(Q))) &&
860-
!match(TrueV, m_Xor(m_Value(Q), m_Specific(FalseV))))
854+
if (!match(TrueV, m_c_Xor(m_Specific(FalseV), m_Value(Q))))
861855
return false;
862856
// Matched: select +++ ? (R >> 1) ^ Q : (R >> 1)
863857
// with commuting ^.

llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3655,8 +3655,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
36553655

36563656
// (A & B) | (A ^ B) --> A | B
36573657
// (B & A) | (A ^ B) --> A | B
3658-
if (match(Op0, m_And(m_Specific(A), m_Specific(B))) ||
3659-
match(Op0, m_And(m_Specific(B), m_Specific(A))))
3658+
if (match(Op0, m_c_And(m_Specific(A), m_Specific(B))))
36603659
return BinaryOperator::CreateOr(A, B);
36613660

36623661
// ~A | (A ^ B) --> ~(A & B)

0 commit comments

Comments
 (0)