[llvm] [InstCombine] Simplify matcher in InstCombineAndOrXor (NFC) (PR #96665)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 10:06:40 PDT 2024
https://github.com/AtariDreams updated https://github.com/llvm/llvm-project/pull/96665
>From accf254ae7ee40138f97d458e74bb767329e0b7d Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Tue, 25 Jun 2024 12:38:42 -0400
Subject: [PATCH] [InstCombine] Simplify matcher in InstCombineAndOrXor (NFC)
---
.../Hexagon/HexagonLoopIdiomRecognition.cpp | 18 ++++++------------
.../InstCombine/InstCombineAndOrXor.cpp | 3 +--
2 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
index 7777ae23e8aec..5a383b23a8338 100644
--- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
@@ -770,8 +770,7 @@ bool PolynomialMultiplyRecognize::matchLeftShift(SelectInst *SelI,
// select +++ ? T : 0
Value *U = *SelI->user_begin();
- if (!match(U, m_Xor(m_Specific(SelI), m_Value(R))) &&
- !match(U, m_Xor(m_Value(R), m_Specific(SelI))))
+ if (!match(U, m_c_Xor(m_Specific(SelI), m_Value(R))))
return false;
// Matched: xor (select +++ ? 0 : T), R
// xor (select +++ ? T : 0), R
@@ -814,15 +813,13 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
CmpInst::Predicate P;
bool TrueIfZero;
- if (match(CondV, m_ICmp(P, m_Value(C), m_Zero())) ||
- match(CondV, m_ICmp(P, m_Zero(), m_Value(C)))) {
+ if (match(CondV, m_c_ICmp(P, m_Value(C), m_Zero()))) {
if (P != CmpInst::ICMP_EQ && P != CmpInst::ICMP_NE)
return false;
// Matched: select C == 0 ? ... : ...
// select C != 0 ? ... : ...
TrueIfZero = (P == CmpInst::ICMP_EQ);
- } else if (match(CondV, m_ICmp(P, m_Value(C), m_One())) ||
- match(CondV, m_ICmp(P, m_One(), m_Value(C)))) {
+ } else if (match(CondV, m_c_ICmp(P, m_Value(C), m_One()))) {
if (P != CmpInst::ICMP_EQ && P != CmpInst::ICMP_NE)
return false;
// Matched: select C == 1 ? ... : ...
@@ -832,8 +829,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
return false;
Value *X = nullptr;
- if (!match(C, m_And(m_Value(X), m_One())) &&
- !match(C, m_And(m_One(), m_Value(X))))
+ if (!match(C, m_c_And(m_Value(X), m_One())))
return false;
// Matched: select (X & 1) == +++ ? ... : ...
// select (X & 1) != +++ ? ... : ...
@@ -845,8 +841,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
if (!match(TrueV, m_LShr(m_Value(R), m_One())))
return false;
// Matched: select +++ ? (R >> 1) : ...
- if (!match(FalseV, m_Xor(m_Specific(TrueV), m_Value(Q))) &&
- !match(FalseV, m_Xor(m_Value(Q), m_Specific(TrueV))))
+ if (!match(FalseV, m_c_Xor(m_Specific(TrueV), m_Value(Q))))
return false;
// Matched: select +++ ? (R >> 1) : (R >> 1) ^ Q
// with commuting ^.
@@ -856,8 +851,7 @@ bool PolynomialMultiplyRecognize::matchRightShift(SelectInst *SelI,
if (!match(FalseV, m_LShr(m_Value(R), m_One())))
return false;
// Matched: select +++ ? ... : (R >> 1)
- if (!match(TrueV, m_Xor(m_Specific(FalseV), m_Value(Q))) &&
- !match(TrueV, m_Xor(m_Value(Q), m_Specific(FalseV))))
+ if (!match(TrueV, m_c_Xor(m_Specific(FalseV), m_Value(Q))))
return false;
// Matched: select +++ ? (R >> 1) ^ Q : (R >> 1)
// with commuting ^.
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 19a12343748df..b8664089c36ce 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3655,8 +3655,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
// (A & B) | (A ^ B) --> A | B
// (B & A) | (A ^ B) --> A | B
- if (match(Op0, m_And(m_Specific(A), m_Specific(B))) ||
- match(Op0, m_And(m_Specific(B), m_Specific(A))))
+ if (match(Op0, m_c_And(m_Specific(A), m_Specific(B))))
return BinaryOperator::CreateOr(A, B);
// ~A | (A ^ B) --> ~(A & B)
More information about the llvm-commits
mailing list