[llvm] 5f094a2 - [DAGCombiner][NFC] Use `m_Value(N, Pattern)` overload to simplify matching (#207154)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 04:26:22 PDT 2026
Author: Pengcheng Wang
Date: 2026-07-02T19:26:18+08:00
New Revision: 5f094a2734d7be1fa280b1ab15637847b728851d
URL: https://github.com/llvm/llvm-project/commit/5f094a2734d7be1fa280b1ab15637847b728851d
DIFF: https://github.com/llvm/llvm-project/commit/5f094a2734d7be1fa280b1ab15637847b728851d.diff
LOG: [DAGCombiner][NFC] Use `m_Value(N, Pattern)` overload to simplify matching (#207154)
Replace the `m_AllOf(Pattern, m_Value(N))` idiom (match-and-bind) with
the
`m_Value(N, Pattern)` overload throughout `DAGCombiner`, and fold
standalone
negative `sd_match` checks into the pattern via `m_Unless` where
applicable.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index e04e9578a3232..fdb5658629e54 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -1372,18 +1372,14 @@ SDValue DAGCombiner::reassociateReduction(unsigned RedOpc, unsigned Opc,
// op(vecreduce(op(a, c)), op(b, d)), to combine the reductions into a
// single node.
SDValue A, B, C, D, RedA, RedB;
- if (sd_match(N0, m_OneUse(m_c_BinOp(
- Opc,
- m_AllOf(m_OneUse(m_UnaryOp(RedOpc, m_Value(A))),
- m_Value(RedA)),
- m_Value(B)))) &&
- sd_match(N1, m_OneUse(m_c_BinOp(
- Opc,
- m_AllOf(m_OneUse(m_UnaryOp(RedOpc, m_Value(C))),
- m_Value(RedB)),
- m_Value(D)))) &&
- !sd_match(B, m_UnaryOp(RedOpc, m_Value())) &&
- !sd_match(D, m_UnaryOp(RedOpc, m_Value())) &&
+ if (sd_match(N0,
+ m_OneUse(m_c_BinOp(
+ Opc, m_Value(RedA, m_OneUse(m_UnaryOp(RedOpc, m_Value(A)))),
+ m_Value(B, m_Unless(m_UnaryOp(RedOpc, m_Value())))))) &&
+ sd_match(N1,
+ m_OneUse(m_c_BinOp(
+ Opc, m_Value(RedB, m_OneUse(m_UnaryOp(RedOpc, m_Value(C)))),
+ m_Value(D, m_Unless(m_UnaryOp(RedOpc, m_Value())))))) &&
A.getValueType() == C.getValueType() &&
hasOperation(Opc, A.getValueType()) &&
TLI.shouldReassociateReduction(RedOpc, VT)) {
@@ -4331,7 +4327,7 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
// Note that these two are applicable to both signed and unsigned min/max.
SDValue X;
SDValue S0;
- auto NegPat = m_AllOf(m_Neg(m_Deferred(X)), m_Value(S0));
+ auto NegPat = m_Value(S0, m_Neg(m_Deferred(X)));
if (sd_match(N1, m_OneUse(m_AnyOf(m_SMax(m_Value(X), NegPat),
m_UMax(m_Value(X), NegPat),
m_SMin(m_Value(X), NegPat),
@@ -5802,11 +5798,9 @@ SDValue DAGCombiner::visitAVG(SDNode *N) {
(Opcode == ISD::AVGFLOORS && hasOperation(ISD::AVGCEILS, VT))) {
SDValue Add;
if (sd_match(N,
- m_c_BinOp(Opcode,
- m_AllOf(m_Value(Add), m_Add(m_Value(X), m_Value(Y))),
+ m_c_BinOp(Opcode, m_Value(Add, m_Add(m_Value(X), m_Value(Y))),
m_One())) ||
- sd_match(N, m_c_BinOp(Opcode,
- m_AllOf(m_Value(Add), m_Add(m_Value(X), m_One())),
+ sd_match(N, m_c_BinOp(Opcode, m_Value(Add, m_Add(m_Value(X), m_One())),
m_Value(Y)))) {
if (IsSigned && Add->getFlags().hasNoSignedWrap())
More information about the llvm-commits
mailing list