[llvm] [DAG] Add `SDPatternMatch::m_Load` (PR #145481)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 09:43:20 PDT 2025
================
@@ -513,6 +513,12 @@ m_VSelect(const T0_P &Cond, const T1_P &T, const T2_P &F) {
return TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::VSELECT, Cond, T, F);
}
+template <typename T0_P, typename T1_P, typename T2_P>
+inline TernaryOpc_match<T0_P, T1_P, T2_P>
+m_Load(const T0_P &Ch, const T1_P &Ptr, const T2_P &Offset) {
+ return TernaryOpc_match<T0_P, T1_P, T2_P>(ISD::LOAD, Ch, Ptr, Offset);
----------------
mshockwave wrote:
I think having a way to distinguish which (SDValue) result to match would indeed be helpful. For instance, to match a SDNode with optional input chain, we can't tell if operand 0 is a chain or not, other than something like `m_AllOf(m_SpecificVT(MVT::Other), <matcher for operand 0>)` or using a matching class that uses `EffectiveOperand`, which skips over chains and glues (but not every matching classes use it).
Not necessary for this patch, but we might want a more general solution, for instance `m_Result<0>(m_Load(...))` for matching the first result of a load.
https://github.com/llvm/llvm-project/pull/145481
More information about the llvm-commits
mailing list