[llvm] 934438a - [VPlanPatternMatch] Unify and clarify m_Isa (NFC) (#189941)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 12:48:51 PDT 2026
Author: Ramkumar Ramachandra
Date: 2026-04-01T20:48:46+01:00
New Revision: 934438ad86fcd623e100a74ddfe7f05e829a5497
URL: https://github.com/llvm/llvm-project/commit/934438ad86fcd623e100a74ddfe7f05e829a5497
DIFF: https://github.com/llvm/llvm-project/commit/934438ad86fcd623e100a74ddfe7f05e829a5497.diff
LOG: [VPlanPatternMatch] Unify and clarify m_Isa (NFC) (#189941)
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
index cb4da3424af2e..86fc518e3a7e0 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
@@ -43,14 +43,19 @@ template <typename Pattern> bool match(VPSingleDefRecipe *R, const Pattern &P) {
return P.match(static_cast<const VPRecipeBase *>(R));
}
-template <typename... Classes> struct class_match {
- template <typename ITy> bool match(ITy *V) const {
- return isa<Classes...>(V);
+/// A match-wrapper around isa.
+template <typename... To> struct match_isapred {
+ template <typename ArgTy> bool match(const ArgTy *V) const {
+ return isa<To...>(V);
}
};
+template <typename... To> inline match_isapred<To...> m_Isa() {
+ return match_isapred<To...>();
+}
+
/// Match an arbitrary VPValue and ignore it.
-inline class_match<VPValue> m_VPValue() { return class_match<VPValue>(); }
+inline auto m_VPValue() { return m_Isa<VPValue>(); }
template <typename Class> struct bind_ty {
Class *&VR;
@@ -219,20 +224,6 @@ struct match_poison {
}
};
-template <typename OpTy, typename... To> struct match_isa {
- OpTy Op;
-
- template <typename FromTy> bool match(FromTy *V) const {
- return isa<To...>(V) && Op.match(V);
- }
-};
-
-// Match isa<Ty>.
-template <typename... To, typename OpTy>
-inline match_isa<OpTy, To...> m_IsA(const OpTy &Op) {
- return {Op};
-}
-
/// Match a VPIRValue that's poison.
inline match_poison m_Poison() { return match_poison(); }
@@ -607,8 +598,14 @@ m_ZExtOrSExt(const Op0_t &Op0) {
return m_CombineOr(m_ZExt(Op0), m_SExt(Op0));
}
+/// A variant of m_Isa that also matches SubPattern.
+template <typename... To, typename SubPattern>
+inline auto m_Isa(const SubPattern &P) {
+ return m_CombineAnd(m_Isa<To...>(), P);
+}
+
template <typename Op0_t> inline auto m_WidenAnyExtend(const Op0_t &Op0) {
- return m_IsA<VPWidenCastRecipe>(m_CombineOr(m_ZExtOrSExt(Op0), m_FPExt(Op0)));
+ return m_Isa<VPWidenCastRecipe>(m_CombineOr(m_ZExtOrSExt(Op0), m_FPExt(Op0)));
}
template <typename Op0_t>
@@ -868,7 +865,7 @@ inline auto m_c_LogicalOr(const Op0_t &Op0, const Op1_t &Op1) {
return m_c_Select(Op0, m_True(), Op1);
}
-inline auto m_CanonicalIV() { return class_match<VPCanonicalIVPHIRecipe>(); }
+inline auto m_CanonicalIV() { return m_Isa<VPCanonicalIVPHIRecipe>(); }
template <typename Op0_t, typename Op1_t, typename Op2_t>
inline auto m_ScalarIVSteps(const Op0_t &Op0, const Op1_t &Op1,
@@ -1061,7 +1058,7 @@ m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) {
return m_CombineAnd(m_Intrinsic<IntrID>(Op0, Op1, Op2), m_Argument<3>(Op3));
}
-inline auto m_LiveIn() { return class_match<VPIRValue, VPSymbolicValue>(); }
+inline auto m_LiveIn() { return m_Isa<VPIRValue, VPSymbolicValue>(); }
/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
/// and bind the source element type and operands.
More information about the llvm-commits
mailing list