[llvm] [VPlan] Make canonical IV part of the region (PR #156262)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 22 14:27:44 PDT 2026


================
@@ -852,19 +859,20 @@ void VPRegionBlock::print(raw_ostream &O, const Twine &Indent,
 
 void VPRegionBlock::dissolveToCFGLoop() {
   auto *Header = cast<VPBasicBlock>(getEntry());
-  if (auto *CanIV = dyn_cast<VPCanonicalIVPHIRecipe>(&Header->front())) {
-    assert(this == getPlan()->getVectorLoopRegion() &&
-           "Canonical IV must be in the entry of the top-level loop region");
-    auto *ScalarR = VPBuilder(CanIV).createScalarPhi(
-        {CanIV->getStartValue(), CanIV->getBackedgeValue()},
-        CanIV->getDebugLoc(), "index");
+  auto *ExitingLatch = cast<VPBasicBlock>(getExiting());
+  auto *CanIV = getCanonicalIV();
+  if (CanIV->getNumUsers() > 0) {
+    VPlan &Plan = *getPlan();
+    auto *Zero = Plan.getConstantInt(CanIV->getType(), 0);
----------------
ayalz wrote:

```suggestion
    auto *Zero = Plan.getZero(CanIV->getType());
```

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


More information about the llvm-commits mailing list