Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2911,11 +2911,6 @@ void VPlanTransforms::replaceSymbolicStrides(
const DenseMap<Value *, const SCEV *> &StridesMap) {
// Replace VPValues for known constant strides guaranteed by predicate scalar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still holds I think, it make ssure we only replace users that are guaranteed to be dominated by the runtime checks we insert.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is the explanation for the check below, which I think should be kept to ensure we only replace strides we know will be guarded by runtime checks

// 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;
Expand All @@ -2928,7 +2923,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.
Expand All @@ -2942,7 +2937,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);
}
Expand Down