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