Skip to content

Commit 9ee51ce

Browse files
committed
[LV] Remove IVEndValues, use resume value directly from fixed phi.(NFC)
1 parent a25d63b commit 9ee51ce

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,8 @@ class InnerLoopVectorizer {
546546

547547
/// Set up the values of the IVs correctly when exiting the vector loop.
548548
virtual void fixupIVUsers(PHINode *OrigPhi, const InductionDescriptor &II,
549-
Value *VectorTripCount, Value *EndValue,
550-
BasicBlock *MiddleBlock, VPlan &Plan,
551-
VPTransformState &State);
549+
Value *VectorTripCount, BasicBlock *MiddleBlock,
550+
VPlan &Plan, VPTransformState &State);
552551

553552
/// Iteratively sink the scalarized operands of a predicated instruction into
554553
/// the block that was created for it.
@@ -668,10 +667,6 @@ class InnerLoopVectorizer {
668667
// Record whether runtime checks are added.
669668
bool AddedSafetyChecks = false;
670669

671-
// Holds the end values for each induction variable. We save the end values
672-
// so we can later fix-up the external users of the induction variables.
673-
DenseMap<PHINode *, Value *> IVEndValues;
674-
675670
/// BFI and PSI are used to check for profile guided size optimizations.
676671
BlockFrequencyInfo *BFI;
677672
ProfileSummaryInfo *PSI;
@@ -786,9 +781,8 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
786781
void printDebugTracesAtEnd() override;
787782

788783
void fixupIVUsers(PHINode *OrigPhi, const InductionDescriptor &II,
789-
Value *VectorTripCount, Value *EndValue,
790-
BasicBlock *MiddleBlock, VPlan &Plan,
791-
VPTransformState &State) override {};
784+
Value *VectorTripCount, BasicBlock *MiddleBlock,
785+
VPlan &Plan, VPTransformState &State) override {};
792786
};
793787

794788
// A specialized derived class of inner loop vectorizer that performs
@@ -2581,7 +2575,7 @@ void InnerLoopVectorizer::createInductionResumeValue(
25812575
assert(VectorTripCount && "Expected valid arguments");
25822576

25832577
Instruction *OldInduction = Legal->getPrimaryInduction();
2584-
Value *&EndValue = IVEndValues[OrigPhi];
2578+
Value *EndValue = nullptr;
25852579
Value *EndValueFromAdditionalBypass = AdditionalBypass.second;
25862580
if (OrigPhi == OldInduction) {
25872581
// We know what the end value is.
@@ -2736,7 +2730,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
27362730
// value for the IV when arriving directly from the middle block.
27372731
void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
27382732
const InductionDescriptor &II,
2739-
Value *VectorTripCount, Value *EndValue,
2733+
Value *VectorTripCount,
27402734
BasicBlock *MiddleBlock, VPlan &Plan,
27412735
VPTransformState &State) {
27422736
// There are two kinds of external IV usages - those that use the value
@@ -2748,6 +2742,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
27482742

27492743
DenseMap<Value *, Value *> MissingVals;
27502744

2745+
Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock(
2746+
OrigLoop->getLoopPreheader()))
2747+
->getIncomingValueForBlock(MiddleBlock);
2748+
27512749
// An external user of the last iteration's value should see the value that
27522750
// the remainder loop uses to initialize its own IV.
27532751
Value *PostInc = OrigPhi->getIncomingValueForBlock(OrigLoop->getLoopLatch());
@@ -2951,8 +2949,8 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
29512949
// Fix-up external users of the induction variables.
29522950
for (const auto &Entry : Legal->getInductionVars())
29532951
fixupIVUsers(Entry.first, Entry.second,
2954-
getOrCreateVectorTripCount(nullptr),
2955-
IVEndValues[Entry.first], LoopMiddleBlock, Plan, State);
2952+
getOrCreateVectorTripCount(nullptr), LoopMiddleBlock, Plan,
2953+
State);
29562954
}
29572955

29582956
for (Instruction *PI : PredicatedInstructions)

0 commit comments

Comments
 (0)