[llvm] [VPlan] Create AVL as a phi from TC -> 0 with EVL tail folding (PR #151481)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 02:54:22 PDT 2025


================
@@ -2350,9 +2350,11 @@ bool VPlanTransforms::tryAddExplicitVectorLength(
   auto *EVLPhi = new VPEVLBasedIVPHIRecipe(StartV, DebugLoc());
   EVLPhi->insertAfter(CanonicalIVPHI);
   VPBuilder Builder(Header, Header->getFirstNonPhi());
-  // Compute original TC - IV as the AVL (application vector length).
-  VPValue *AVL = Builder.createNaryOp(
-      Instruction::Sub, {Plan.getTripCount(), EVLPhi}, DebugLoc(), "avl");
+  // Create the AVL, starting from TC -> 0 in steps of EVL.
+  VPPhi *AVLPhi =
+      Builder.createScalarPhi({Plan.getTripCount()}, DebugLoc(), "avl");
+  VPValue *AVL = AVLPhi;
----------------
artagnon wrote:

```suggestion
```

Would be good to s/AVL/AVLPhi/ later.

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


More information about the llvm-commits mailing list