[llvm] [VPlan] Check enclosing region first (NFC). (PR #216676)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 10:16:51 PDT 2026


https://github.com/fhahn updated https://github.com/llvm/llvm-project/pull/216676

>From 016c27ecef5e314f754e52948bc3cbacdce2b5bd Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Sun, 9 Aug 2026 09:48:01 +0100
Subject: [PATCH] [VPlan] Check enclosing region first (NFC).

Check cheaper getEnclosingLoopRegion() first; it only walks the parent chain, while
getVectorLoopRegion() traverses the plan's top-level blocks.
---
 llvm/lib/Transforms/Vectorize/VPlan.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f077932cf7217..87d24ed9d8d4b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1485,8 +1485,8 @@ static bool isDefinedInsideLoopRegions(const VPValue *VPV) {
   if (isa<VPRegionValue>(VPV))
     return true;
   const VPRecipeBase *DefR = VPV->getDefiningRecipe();
-  return DefR && (!DefR->getParent()->getPlan()->getVectorLoopRegion() ||
-                  DefR->getParent()->getEnclosingLoopRegion());
+  return DefR && (DefR->getParent()->getEnclosingLoopRegion() ||
+                  !DefR->getParent()->getPlan()->getVectorLoopRegion());
 }
 
 bool VPValue::isDefinedOutsideLoopRegions() const {



More information about the llvm-commits mailing list