[llvm] 79cfb6f - [SDPatternMatch] Implement conditionally binding a value by using m_AllOf. NFC (#225559)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 12:51:16 PDT 2026
Author: Craig Topper
Date: 2026-09-23T12:51:08-07:00
New Revision: 79cfb6f2871f3bc5a75697e29e4ac110605a1a9f
URL: https://github.com/llvm/llvm-project/commit/79cfb6f2871f3bc5a75697e29e4ac110605a1a9f
DIFF: https://github.com/llvm/llvm-project/commit/79cfb6f2871f3bc5a75697e29e4ac110605a1a9f.diff
LOG: [SDPatternMatch] Implement conditionally binding a value by using m_AllOf. NFC (#225559)
Making the predicate part of Value_bind has a non-zero code size and
compile time impact. I assume this is because the non conditional
m_Value needs a dummy predicate.
This patch removes the predicate from Value_bind and uses a m_AllOf so
we only pay for the predicate when we need it. This matches how this is
currently done in IR PatternMatch.
Added:
Modified:
llvm/include/llvm/CodeGen/SDPatternMatch.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/SDPatternMatch.h b/llvm/include/llvm/CodeGen/SDPatternMatch.h
index 0eb174531cd70..c0ad641f86db2 100644
--- a/llvm/include/llvm/CodeGen/SDPatternMatch.h
+++ b/llvm/include/llvm/CodeGen/SDPatternMatch.h
@@ -266,29 +266,23 @@ template <unsigned N> inline NUses_match<N, Value_match> m_NUses() {
return NUses_match<N, Value_match>(m_Value());
}
-template <typename PredPattern> struct Value_bind {
+struct Value_bind {
SDValue &BindVal;
- PredPattern Pred;
- Value_bind(SDValue &N, const PredPattern &P) : BindVal(N), Pred(P) {}
+ Value_bind(SDValue &N) : BindVal(N) {}
template <typename MatchContext>
bool match(const MatchContext &Ctx, SDValue N) {
- if (!Pred.match(Ctx, N))
- return false;
-
BindVal = N;
return true;
}
};
-inline auto m_Value(SDValue &N) {
- return Value_bind<Value_match>(N, m_Value());
-}
+inline auto m_Value(SDValue &N) { return Value_bind(N); }
/// Conditionally bind an SDValue based on the predicate.
template <typename PredPattern>
inline auto m_Value(SDValue &N, const PredPattern &P) {
- return Value_bind<PredPattern>(N, P);
+ return m_AllOf(P, Value_bind(N));
}
template <typename Pattern, typename PredFuncT> struct TLI_pred_match {
More information about the llvm-commits
mailing list