[llvm] [VPlan] Permit derived IV in isHeaderMask (PR #187360)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 18 12:08:01 PDT 2026


https://github.com/john-brawn-arm created https://github.com/llvm/llvm-project/pull/187360

When matching scalar steps of the canonical IV, also match a derived IV of the canonical IV if the derivation is essentially a no-op. Fixes a failure in the mve-reg-pressure-spills.ll test when expensive checks are enabled.

>From 8b126d47d15310c4eb8af5c12927169dc6b78b28 Mon Sep 17 00:00:00 2001
From: John Brawn <john.brawn at arm.com>
Date: Wed, 18 Mar 2026 18:58:50 +0000
Subject: [PATCH] [VPlan] Permit derived IV in isHeaderMask

When matching scalar steps of the canonical IV, also match a derived
IV of the canonical IV if the derivation is essentially a no-op.
Fixes a failure in the mve-reg-pressure-spills.ll test when expensive
checks are enabled.
---
 llvm/lib/Transforms/Vectorize/VPlanUtils.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
index ae6fb8e3e9cf5..7921a6fa0411e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanUtils.cpp
@@ -62,9 +62,10 @@ bool vputils::isHeaderMask(const VPValue *V, const VPlan &Plan) {
 
   VPValue *A, *B;
 
-  auto m_CanonicalScalarIVSteps =
-      m_ScalarIVSteps(m_Specific(Plan.getVectorLoopRegion()->getCanonicalIV()),
-                      m_One(), m_Specific(&Plan.getVF()));
+  auto m_CanonicalScalarIVSteps = m_ScalarIVSteps(
+      m_CombineOr(m_CanonicalIV(),
+                  m_DerivedIV(m_ZeroInt(), m_CanonicalIV(), m_One())),
+      m_One(), m_Specific(&Plan.getVF()));
 
   if (match(V, m_ActiveLaneMask(m_VPValue(A), m_VPValue(B), m_One())))
     return B == Plan.getTripCount() &&



More information about the llvm-commits mailing list