Skip to content

Commit b8b393e

Browse files
committed
[LV] Remove IVEndValues, use resume value directly from fixed phi.(NFC)
1 parent 71a1db6 commit b8b393e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ class InnerLoopVectorizer {
542542

543543
/// Set up the values of the IVs correctly when exiting the vector loop.
544544
virtual void fixupIVUsers(PHINode *OrigPhi, const InductionDescriptor &II,
545-
Value *VectorTripCount, Value *EndValue,
546-
BasicBlock *MiddleBlock, VPTransformState &State);
545+
Value *VectorTripCount, BasicBlock *MiddleBlock,
546+
VPTransformState &State);
547547

548548
/// Iteratively sink the scalarized operands of a predicated instruction into
549549
/// the block that was created for it.
@@ -656,10 +656,6 @@ class InnerLoopVectorizer {
656656
// Record whether runtime checks are added.
657657
bool AddedSafetyChecks = false;
658658

659-
// Holds the end values for each induction variable. We save the end values
660-
// so we can later fix-up the external users of the induction variables.
661-
DenseMap<PHINode *, Value *> IVEndValues;
662-
663659
/// BFI and PSI are used to check for profile guided size optimizations.
664660
BlockFrequencyInfo *BFI;
665661
ProfileSummaryInfo *PSI;
@@ -774,8 +770,7 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
774770
void printDebugTracesAtEnd() override;
775771

776772
void fixupIVUsers(PHINode *OrigPhi, const InductionDescriptor &II,
777-
Value *VectorTripCount, Value *EndValue,
778-
BasicBlock *MiddleBlock,
773+
Value *VectorTripCount, BasicBlock *MiddleBlock,
779774
VPTransformState &State) override {};
780775
};
781776

@@ -2607,7 +2602,7 @@ void InnerLoopVectorizer::createInductionResumeValue(
26072602
assert(VectorTripCount && "Expected valid arguments");
26082603

26092604
Instruction *OldInduction = Legal->getPrimaryInduction();
2610-
Value *&EndValue = IVEndValues[OrigPhi];
2605+
Value *EndValue = nullptr;
26112606
Value *EndValueFromAdditionalBypass = AdditionalBypass.second;
26122607
if (OrigPhi == OldInduction) {
26132608
// We know what the end value is.
@@ -2759,7 +2754,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
27592754
// value for the IV when arriving directly from the middle block.
27602755
void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
27612756
const InductionDescriptor &II,
2762-
Value *VectorTripCount, Value *EndValue,
2757+
Value *VectorTripCount,
27632758
BasicBlock *MiddleBlock,
27642759
VPTransformState &State) {
27652760
// There are two kinds of external IV usages - those that use the value
@@ -2771,6 +2766,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
27712766

27722767
DenseMap<Value *, Value *> MissingVals;
27732768

2769+
Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock(
2770+
OrigLoop->getLoopPreheader()))
2771+
->getIncomingValueForBlock(MiddleBlock);
2772+
27742773
// An external user of the last iteration's value should see the value that
27752774
// the remainder loop uses to initialize its own IV.
27762775
Value *PostInc = OrigPhi->getIncomingValueForBlock(OrigLoop->getLoopLatch());
@@ -2973,8 +2972,8 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
29732972
// Fix-up external users of the induction variables.
29742973
for (const auto &Entry : Legal->getInductionVars())
29752974
fixupIVUsers(Entry.first, Entry.second,
2976-
getOrCreateVectorTripCount(nullptr),
2977-
IVEndValues[Entry.first], LoopMiddleBlock, State);
2975+
getOrCreateVectorTripCount(nullptr), LoopMiddleBlock,
2976+
State);
29782977
}
29792978

29802979
for (Instruction *PI : PredicatedInstructions)

0 commit comments

Comments
 (0)