[llvm] [VPlan] Add m_VScale() pattern matcher. (NFC) (PR #207394)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 09:46:58 PDT 2026
https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/207394
>From 142cc55bc75450b0874ff650af6c185cfaa0dc0c Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Fri, 3 Jul 2026 09:38:06 +0100
Subject: [PATCH] [VPlan] Add m_VScale() pattern matcher. (NFC)
Add a dedicated m_VScale() matcher for VPInstruction::VScale, in line
with other VPInstruction matchers.
---
llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h | 4 ++++
llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 11 ++++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
index e2e08c50d06e8..48c395b1102f1 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
@@ -1077,6 +1077,10 @@ inline auto m_WidenIntrinsic(const T &...Ops) {
return m_Isa<VPWidenIntrinsicRecipe>(m_Intrinsic<IntrID>(Ops...));
}
+inline VPInstruction_match<VPInstruction::VScale> m_VScale() {
+ return m_VPInstruction<VPInstruction::VScale>();
+}
+
inline auto m_LiveIn() { return m_Isa<VPIRValue, VPSymbolicValue>(); }
/// Match a GEP recipe (VPWidenGEPRecipe, VPInstruction, or VPReplicateRecipe)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index 747a44c6e3a8d..c686fd9907795 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -694,8 +694,7 @@ VPInstruction *vputils::findCanonicalIVIncrement(VPlan &Plan) {
VPSymbolicValue &UF = Plan.getUF();
if (!UF.isMaterialized())
return Step == &UF ||
- match(Step, m_c_Mul(m_Specific(&Plan.getUF()),
- m_VPInstruction<VPInstruction::VScale>()));
+ match(Step, m_c_Mul(m_Specific(&Plan.getUF()), m_VScale()));
// Alias masking: step is number of active lanes of a dependence mask.
if (match(Step, m_ZExtOrTruncOrSelf(
@@ -709,15 +708,13 @@ VPInstruction *vputils::findCanonicalIVIncrement(VPlan &Plan) {
// Scalable VF: step involves VScale.
if (ConcreteUF == 1)
- return match(Step, m_VPInstruction<VPInstruction::VScale>());
- if (match(Step, m_c_Mul(m_SpecificInt(ConcreteUF),
- m_VPInstruction<VPInstruction::VScale>())))
+ return match(Step, m_VScale());
+ if (match(Step, m_c_Mul(m_SpecificInt(ConcreteUF), m_VScale())))
return true;
// mul(VScale, ConcreteUF) may have been simplified to
// shl(VScale, log2(ConcreteUF)) when ConcreteUF is a power of 2.
return isPowerOf2_32(ConcreteUF) &&
- match(Step, m_Shl(m_VPInstruction<VPInstruction::VScale>(),
- m_SpecificInt(Log2_32(ConcreteUF))));
+ match(Step, m_Shl(m_VScale(), m_SpecificInt(Log2_32(ConcreteUF))));
};
VPInstruction *Increment = nullptr;
More information about the llvm-commits
mailing list