Skip to content

Commit 33a7117

Browse files
committed
Strides only in ph
1 parent 61ceb1a commit 33a7117

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9190,7 +9190,12 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
91909190
auto *CI = Plan->getOrAddLiveIn(
91919191
ConstantInt::get(Stride->getType(), ScevStride->getAPInt()));
91929192
if (VPValue *StrideVPV = Plan->getLiveIn(StrideV))
9193-
StrideVPV->replaceAllUsesWith(CI);
9193+
StrideVPV->replaceUsesWithIf(CI, [&Plan](VPUser &U, unsigned) {
9194+
auto *R = dyn_cast<VPRecipeBase>(&U);
9195+
if (!R)
9196+
return false;
9197+
return R->getParent()->getParent() || R->getParent() == Plan->getVectorLoopRegion()->getSinglePredecessor();
9198+
});
91949199

91959200
// The versioned value may not be used in the loop directly but through a
91969201
// sext/zext. Add new live-ins in those cases.
@@ -9204,7 +9209,12 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
92049209
APInt C = isa<SExtInst>(U) ? ScevStride->getAPInt().sext(BW)
92059210
: ScevStride->getAPInt().zext(BW);
92069211
VPValue *CI = Plan->getOrAddLiveIn(ConstantInt::get(U->getType(), C));
9207-
StrideVPV->replaceAllUsesWith(CI);
9212+
StrideVPV->replaceUsesWithIf(CI, [&Plan](VPUser &U, unsigned) {
9213+
auto *R = dyn_cast<VPRecipeBase>(&U);
9214+
if (!R)
9215+
return false;
9216+
return R->getParent()->getParent() || R->getParent() == Plan->getVectorLoopRegion()->getSinglePredecessor();
9217+
});
92089218
}
92099219
}
92109220

0 commit comments

Comments
 (0)