[llvm] [VPlan] Remove manual constant fold in VPWidenIntOrFpInductionRecipe. NFC (PR #118028)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 28 10:18:55 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Luke Lau (lukel97)

<details>
<summary>Changes</summary>

This manual constant folding was added in 2017 in https://reviews.llvm.org/D29956, but since then it looks like IRBuilder has learnt to fold it away itself.
I'm not sure at what point this happened, I just verified this by stepping through the call to CreateVectorSplat in the debugger.


---
Full diff: https://github.com/llvm/llvm-project/pull/118028.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+1-7) 


``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 24cf4666c62ce3..7bdf50fc6a9686 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -1691,13 +1691,7 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
     Value *Mul = Builder.CreateBinOp(MulOp, Step, RuntimeVF);
 
     // Create a vector splat to use in the induction update.
-    //
-    // FIXME: If the step is non-constant, we create the vector splat with
-    //        IRBuilder. IRBuilder can constant-fold the multiply, but it
-    //        doesn't handle a constant vector splat.
-    SplatVF = isa<Constant>(Mul)
-                  ? ConstantVector::getSplat(State.VF, cast<Constant>(Mul))
-                  : Builder.CreateVectorSplat(State.VF, Mul);
+    SplatVF = Builder.CreateVectorSplat(State.VF, Mul);
   }
 
   Builder.restoreIP(CurrIP);

``````````

</details>


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


More information about the llvm-commits mailing list