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

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 22 08:54:26 PST 2026


================
@@ -744,13 +744,18 @@ static std::pair<VPBlockBase *, VPBlockBase *> cloneFrom(VPBlockBase *Entry) {
 VPRegionBlock *VPRegionBlock::clone() {
   const auto &[NewEntry, NewExiting] = cloneFrom(getEntry());
   VPlan &Plan = *getPlan();
-  VPRegionBlock *NewRegion =
-      isReplicator()
-          ? Plan.createReplicateRegion(NewEntry, NewExiting, getName())
-          : Plan.createLoopRegion(getName(), NewEntry, NewExiting);
+  VPRegionBlock *NewRegion;
+  if (isReplicator()) {
+    NewRegion = Plan.createReplicateRegion(NewEntry, NewExiting, getName());
+  } else {
+    auto *CanIV = CanIVInfo->getVPValue();
+    NewRegion = Plan.createLoopRegion(CanIV->getType(), CanIV->getDebugLoc(),
+                                      getName(), NewEntry, NewExiting);
+  }
----------------
ayalz wrote:

The presence of CanonicalIV identifies loop regions, may be clearer to do:
```suggestion
  VPRegionBlock *NewRegion;
  if (auto *CanIV = getCanonicalIV())
    NewRegion = Plan.createLoopRegion(NewEntry, NewExiting, getName(), CanIV);
  else
    NewRegion = Plan.createReplicateRegion(NewEntry, NewExiting, getName());
```
with a suitable `createLoopRegion()` that accepts a CanIV VPValue* to convey its Type and DL, but otherwise consistent with `createReplicateRegion()`?

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


More information about the llvm-commits mailing list