[llvm] [VPlan] Split out EVL exit cond transform from canonicalizeEVLLoops. NFC (PR #178181)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 30 08:52:18 PST 2026


================
@@ -3302,27 +3286,57 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
   VPRecipeBase *CanonicalIVIncrement = Backedge->getDefiningRecipe();
   CanonicalIVIncrement->eraseFromParent();
   CanonicalIV->eraseFromParent();
+}
+
+void VPlanTransforms::convertEVLExitCond(VPlan &Plan) {
+  VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
+  // The canonical IV may not exist at this stage.
+  if (!LoopRegion ||
+      !isa<VPCanonicalIVPHIRecipe>(LoopRegion->getEntryBasicBlock()->front()))
+    return;
+  VPCanonicalIVPHIRecipe *CanIV = LoopRegion->getCanonicalIV();
+  if (!CanIV || std::next(CanIV->getIterator()) == CanIV->getParent()->end())
----------------
fhahn wrote:

```suggestion
  if (std::next(CanIV->getIterator()) == CanIV->getParent()->end())
```

After the check above, CanIV should always be != null

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


More information about the llvm-commits mailing list