[llvm] [VPlan] Strip dead code in replaceSymbolicStrides (NFC) (PR #164296)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 11:22:46 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
CanUseVersionedStride is checking that the value is modeled in VPlan, but we can use replaceAllUsesWith unconditionally for this.
---
Full diff: https://github.com/llvm/llvm-project/pull/164296.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+2-9)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index e060e7081042a..cafddcc77d15d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -2909,13 +2909,6 @@ void VPlanTransforms::canonicalizeEVLLoops(VPlan &Plan) {
void VPlanTransforms::replaceSymbolicStrides(
VPlan &Plan, PredicatedScalarEvolution &PSE,
const DenseMap<Value *, const SCEV *> &StridesMap) {
- // Replace VPValues for known constant strides guaranteed by predicate scalar
- // evolution.
- auto CanUseVersionedStride = [&Plan](VPUser &U, unsigned) {
- auto *R = cast<VPRecipeBase>(&U);
- return R->getRegion() ||
- R->getParent() == Plan.getVectorLoopRegion()->getSinglePredecessor();
- };
ValueToSCEVMapTy RewriteMap;
for (const SCEV *Stride : StridesMap.values()) {
using namespace SCEVPatternMatch;
@@ -2928,7 +2921,7 @@ void VPlanTransforms::replaceSymbolicStrides(
auto *CI =
Plan.getOrAddLiveIn(ConstantInt::get(Stride->getType(), *StrideConst));
if (VPValue *StrideVPV = Plan.getLiveIn(StrideV))
- StrideVPV->replaceUsesWithIf(CI, CanUseVersionedStride);
+ StrideVPV->replaceAllUsesWith(CI);
// The versioned value may not be used in the loop directly but through a
// sext/zext. Add new live-ins in those cases.
@@ -2942,7 +2935,7 @@ void VPlanTransforms::replaceSymbolicStrides(
APInt C =
isa<SExtInst>(U) ? StrideConst->sext(BW) : StrideConst->zext(BW);
VPValue *CI = Plan.getOrAddLiveIn(ConstantInt::get(U->getType(), C));
- StrideVPV->replaceUsesWithIf(CI, CanUseVersionedStride);
+ StrideVPV->replaceAllUsesWith(CI);
}
RewriteMap[StrideV] = PSE.getSCEV(StrideV);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/164296
More information about the llvm-commits
mailing list