[llvm] [VPlan] Replace VPRegionBlock with explicit CFG before execute (NFCI). (PR #117506)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 02:19:05 PDT 2025


================
@@ -1365,17 +1397,18 @@ void VPlanPrinter::dumpRegion(const VPRegionBlock *Region) {
 
 #endif
 
-/// Returns true if there is a vector loop region and \p VPV is defined in a
-/// loop region.
-static bool isDefinedInsideLoopRegions(const VPValue *VPV) {
-  const VPRecipeBase *DefR = VPV->getDefiningRecipe();
-  return DefR && (!DefR->getParent()->getPlan()->getVectorLoopRegion() ||
-                  DefR->getParent()->getEnclosingLoopRegion());
-}
+bool VPValue::isDefinedOutsideLoop() const {
+  auto *DefR = getDefiningRecipe();
+  if (!DefR)
+    return true;
 
-bool VPValue::isDefinedOutsideLoopRegions() const {
-  return !isDefinedInsideLoopRegions(this);
+  // For non-live-ins, check if is in a region only if the top-level loop region
+  // still exits.
+  const VPBasicBlock *DefVPBB = DefR->getParent();
+  auto *Plan = DefVPBB->getPlan();
+  return Plan->getVectorLoopRegion() && !DefVPBB->getEnclosingLoopRegion();
----------------
fhahn wrote:

The previous`isDefinedOutsideLoopRegions` would return true if there are no loop regions (because the only possible case was when it had been removed). Now we need to be more conservative, because the regions will be removed, but loops still remain.

https://github.com/llvm/llvm-project/pull/117506


More information about the llvm-commits mailing list