@@ -546,8 +546,8 @@ class InnerLoopVectorizer {
546
546
547
547
// / Set up the values of the IVs correctly when exiting the vector loop.
548
548
virtual void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II,
549
- Value *VectorTripCount, Value *EndValue ,
550
- BasicBlock *MiddleBlock, VPTransformState &State);
549
+ Value *VectorTripCount, BasicBlock *MiddleBlock ,
550
+ VPTransformState &State);
551
551
552
552
// / Iteratively sink the scalarized operands of a predicated instruction into
553
553
// / the block that was created for it.
@@ -664,10 +664,6 @@ class InnerLoopVectorizer {
664
664
// Record whether runtime checks are added.
665
665
bool AddedSafetyChecks = false ;
666
666
667
- // Holds the end values for each induction variable. We save the end values
668
- // so we can later fix-up the external users of the induction variables.
669
- DenseMap<PHINode *, Value *> IVEndValues;
670
-
671
667
// / BFI and PSI are used to check for profile guided size optimizations.
672
668
BlockFrequencyInfo *BFI;
673
669
ProfileSummaryInfo *PSI;
@@ -782,8 +778,7 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
782
778
void printDebugTracesAtEnd () override ;
783
779
784
780
void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II,
785
- Value *VectorTripCount, Value *EndValue,
786
- BasicBlock *MiddleBlock,
781
+ Value *VectorTripCount, BasicBlock *MiddleBlock,
787
782
VPTransformState &State) override {};
788
783
};
789
784
@@ -2615,7 +2610,7 @@ void InnerLoopVectorizer::createInductionResumeValue(
2615
2610
assert (VectorTripCount && " Expected valid arguments" );
2616
2611
2617
2612
Instruction *OldInduction = Legal->getPrimaryInduction ();
2618
- Value *& EndValue = IVEndValues[OrigPhi] ;
2613
+ Value *EndValue = nullptr ;
2619
2614
Value *EndValueFromAdditionalBypass = AdditionalBypass.second ;
2620
2615
if (OrigPhi == OldInduction) {
2621
2616
// We know what the end value is.
@@ -2771,7 +2766,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
2771
2766
// value for the IV when arriving directly from the middle block.
2772
2767
void InnerLoopVectorizer::fixupIVUsers (PHINode *OrigPhi,
2773
2768
const InductionDescriptor &II,
2774
- Value *VectorTripCount, Value *EndValue,
2769
+ Value *VectorTripCount,
2775
2770
BasicBlock *MiddleBlock,
2776
2771
VPTransformState &State) {
2777
2772
// There are two kinds of external IV usages - those that use the value
@@ -2783,6 +2778,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
2783
2778
2784
2779
DenseMap<Value *, Value *> MissingVals;
2785
2780
2781
+ Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock (
2782
+ OrigLoop->getLoopPreheader ()))
2783
+ ->getIncomingValueForBlock (MiddleBlock);
2784
+
2786
2785
// An external user of the last iteration's value should see the value that
2787
2786
// the remainder loop uses to initialize its own IV.
2788
2787
Value *PostInc = OrigPhi->getIncomingValueForBlock (OrigLoop->getLoopLatch ());
@@ -2985,8 +2984,8 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
2985
2984
// Fix-up external users of the induction variables.
2986
2985
for (const auto &Entry : Legal->getInductionVars ())
2987
2986
fixupIVUsers (Entry.first , Entry.second ,
2988
- getOrCreateVectorTripCount (nullptr ),
2989
- IVEndValues[Entry. first ], LoopMiddleBlock, State);
2987
+ getOrCreateVectorTripCount (nullptr ), LoopMiddleBlock,
2988
+ State);
2990
2989
}
2991
2990
2992
2991
for (Instruction *PI : PredicatedInstructions)
0 commit comments