Skip to content

Commit 138452a

Browse files
committed
[Unrelated code] Remove Mel-Chen:legalizeAndOptimizeInductions
We should reopen it after supporting const strided accessess.
1 parent 8686e9c commit 138452a

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -626,14 +626,12 @@ static SmallVector<VPUser *> collectUsersRecursively(VPValue *V) {
626626
static void legalizeAndOptimizeInductions(VPlan &Plan) {
627627
using namespace llvm::VPlanPatternMatch;
628628
VPBasicBlock *HeaderVPBB = Plan.getVectorLoopRegion()->getEntryBasicBlock();
629-
SmallVector<VPWidenInductionRecipe *, 4> InductionPhis;
630-
for (VPRecipeBase &R : HeaderVPBB->phis())
631-
if (auto *IV = dyn_cast<VPWidenInductionRecipe>(&R))
632-
InductionPhis.push_back(IV);
633-
634629
bool HasOnlyVectorVFs = !Plan.hasScalarVFOnly();
635-
VPBuilder Builder;
636-
for (VPWidenInductionRecipe *PhiR : reverse(InductionPhis)) {
630+
VPBuilder Builder(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
631+
for (VPRecipeBase &Phi : HeaderVPBB->phis()) {
632+
auto *PhiR = dyn_cast<VPWidenInductionRecipe>(&Phi);
633+
if (!PhiR)
634+
continue;
637635
// Try to narrow wide and replicating recipes to uniform recipes, based on
638636
// VPlan analysis.
639637
// TODO: Apply to all recipes in the future, to replace legacy uniformity
@@ -643,8 +641,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
643641
auto *Def = dyn_cast<VPSingleDefRecipe>(U);
644642
auto *RepR = dyn_cast<VPReplicateRecipe>(U);
645643
// Skip recipes that shouldn't be narrowed.
646-
if (!Def ||
647-
!isa<VPReplicateRecipe, VPWidenRecipe, VPWidenGEPRecipe>(Def) ||
644+
if (!Def || !isa<VPReplicateRecipe, VPWidenRecipe>(Def) ||
648645
Def->getNumUsers() == 0 || !Def->getUnderlyingValue() ||
649646
(RepR && (RepR->isSingleScalar() || RepR->isPredicated())))
650647
continue;
@@ -657,13 +654,11 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
657654
Def->operands(), /*IsUniform*/ true);
658655
Clone->insertAfter(Def);
659656
Def->replaceAllUsesWith(Clone);
660-
Def->eraseFromParent();
661657
}
662658

663-
Builder.setInsertPoint(HeaderVPBB, HeaderVPBB->getFirstNonPhi());
664659
// Replace wide pointer inductions which have only their scalars used by
665660
// PtrAdd(IndStart, ScalarIVSteps (0, Step)).
666-
if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(PhiR)) {
661+
if (auto *PtrIV = dyn_cast<VPWidenPointerInductionRecipe>(&Phi)) {
667662
if (!PtrIV->onlyScalarsGenerated(Plan.hasScalableVF()))
668663
continue;
669664

@@ -684,7 +679,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
684679

685680
// Replace widened induction with scalar steps for users that only use
686681
// scalars.
687-
auto *WideIV = cast<VPWidenIntOrFpInductionRecipe>(PhiR);
682+
auto *WideIV = cast<VPWidenIntOrFpInductionRecipe>(&Phi);
688683
if (HasOnlyVectorVFs && none_of(WideIV->users(), [WideIV](VPUser *U) {
689684
return U->usesScalars(WideIV);
690685
}))

0 commit comments

Comments
 (0)