[llvm] d835dd2 - [LV] Strip createStepForVF (NFC) (#185668)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 02:04:44 PDT 2026
Author: Ramkumar Ramachandra
Date: 2026-04-02T10:04:37+01:00
New Revision: d835dd2b430c259020e2fc5ce4b1eb1f5a464a07
URL: https://github.com/llvm/llvm-project/commit/d835dd2b430c259020e2fc5ce4b1eb1f5a464a07
DIFF: https://github.com/llvm/llvm-project/commit/d835dd2b430c259020e2fc5ce4b1eb1f5a464a07.diff
LOG: [LV] Strip createStepForVF (NFC) (#185668)
The mul -> shl simplification is already done in VPlan.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlanHelpers.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 32ef10e530187..5ddb47a22e84f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -786,20 +786,6 @@ createLVAnalysis(const char *PassName, StringRef RemarkName, Loop *TheLoop,
namespace llvm {
-/// Return a value for Step multiplied by VF.
-Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
- int64_t Step) {
- assert(Ty->isIntegerTy() && "Expected an integer step");
- ElementCount VFxStep = VF.multiplyCoefficientBy(Step);
- assert(isPowerOf2_64(VF.getKnownMinValue()) && "must pass power-of-2 VF");
- if (VF.isScalable() && isPowerOf2_64(Step)) {
- return B.CreateShl(
- B.CreateVScale(Ty),
- ConstantInt::get(Ty, Log2_64(VFxStep.getKnownMinValue())), "", true);
- }
- return B.CreateElementCount(Ty, VFxStep);
-}
-
/// Return the runtime value for VF.
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF) {
return B.CreateElementCount(Ty, VF);
diff --git a/llvm/lib/Transforms/Vectorize/VPlanHelpers.h b/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
index 0d4a842c700f6..5de7ab36a6d75 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanHelpers.h
@@ -46,10 +46,6 @@ class Value;
/// vectors it is an expression determined at runtime.
Value *getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF);
-/// Return a value for Step multiplied by VF.
-Value *createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF,
- int64_t Step);
-
/// Compute the transformed value of Index at offset StartValue using step
/// StepValue.
/// For integer induction, returns StartValue + Index * StepValue.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 7eefd77045050..05a47273b799a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2606,8 +2606,6 @@ void VPScalarIVStepsRecipe::execute(VPTransformState &State) {
/*ImplicitTrunc=*/true)
: ConstantFP::get(BaseIVTy, Lane);
Value *StartIdx = Builder.CreateBinOp(AddOp, StartIdx0, LaneValue);
- // The step returned by `createStepForVF` is a runtime-evaluated value
- // when VF is scalable. Otherwise, it should be folded into a Constant.
assert((State.VF.isScalable() || isa<Constant>(StartIdx)) &&
"Expected StartIdx to be folded to a constant when VF is not "
"scalable");
@@ -4571,7 +4569,8 @@ void VPWidenCanonicalIVRecipe::execute(VPTransformState &State) {
Value *VStart = VF.isScalar()
? CanonicalIV
: Builder.CreateVectorSplat(VF, CanonicalIV, "broadcast");
- Value *VStep = createStepForVF(Builder, STy, VF, getUnrollPart(*this));
+ Value *VStep = Builder.CreateElementCount(
+ STy, VF.multiplyCoefficientBy(getUnrollPart(*this)));
if (VF.isVector()) {
VStep = Builder.CreateVectorSplat(VF, VStep);
VStep =
More information about the llvm-commits
mailing list