[llvm] [VPlan] Expand VPWidenIntOrFpInductionRecipe into separate recipes (PR #118638)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 07:35:58 PDT 2025


================
@@ -2398,6 +2511,20 @@ void VPlanTransforms::convertToConcreteRecipes(VPlan &Plan,
   SmallVector<VPRecipeBase *> ToRemove;
   for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
            vp_depth_first_deep(Plan.getEntry()))) {
+
+    // Move VPWidenPointerInductionRecipes to the back of the phis
+    // since it may insert non-phi instructions in place, which will
+    // interfere with other header phis if they come after.
+    //
+    // TODO: Expand out VPWidenPointerInductionRecipe into multiple
+    // recipes here and remove this
----------------
lukel97 wrote:

I don't think firstNonPhi is enough, since any VPWidenIntOrFpInductionRecipe that gets executed before a VPWidenPointerInductionRecipe will end up generating something like:

```llvm
  %pointer.phi = phi ptr [ null, %vector.ph ], [ %ptr.ind, %vector.ph ]
  %ptr.ind = getelementptr i8, ptr %pointer.phi, i64 16
  %vector.gep = getelementptr i8, ptr %pointer.phi, <4 x i64> <i64 0, i64 4, i64 8, i64 12>
  %vec.ind = phi <4 x i32>  ; VPWidenIntOrFpInductionRecipe's VPWidenPHI
```

Alternatively, we could tweak VPWidenPHI to always insert its phi at firstNonPhi during execution?

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


More information about the llvm-commits mailing list