@@ -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.
@@ -668,10 +667,6 @@ class InnerLoopVectorizer {
668
667
// Record whether runtime checks are added.
669
668
bool AddedSafetyChecks = false ;
670
669
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
-
675
670
// / BFI and PSI are used to check for profile guided size optimizations.
676
671
BlockFrequencyInfo *BFI;
677
672
ProfileSummaryInfo *PSI;
@@ -786,9 +781,8 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
786
781
void printDebugTracesAtEnd () override ;
787
782
788
783
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 {};
792
786
};
793
787
794
788
// A specialized derived class of inner loop vectorizer that performs
@@ -2581,7 +2575,7 @@ void InnerLoopVectorizer::createInductionResumeValue(
2581
2575
assert (VectorTripCount && " Expected valid arguments" );
2582
2576
2583
2577
Instruction *OldInduction = Legal->getPrimaryInduction ();
2584
- Value *& EndValue = IVEndValues[OrigPhi] ;
2578
+ Value *EndValue = nullptr ;
2585
2579
Value *EndValueFromAdditionalBypass = AdditionalBypass.second ;
2586
2580
if (OrigPhi == OldInduction) {
2587
2581
// We know what the end value is.
@@ -2736,7 +2730,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
2736
2730
// value for the IV when arriving directly from the middle block.
2737
2731
void InnerLoopVectorizer::fixupIVUsers (PHINode *OrigPhi,
2738
2732
const InductionDescriptor &II,
2739
- Value *VectorTripCount, Value *EndValue,
2733
+ Value *VectorTripCount,
2740
2734
BasicBlock *MiddleBlock, VPlan &Plan,
2741
2735
VPTransformState &State) {
2742
2736
// There are two kinds of external IV usages - those that use the value
@@ -2748,6 +2742,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
2748
2742
2749
2743
DenseMap<Value *, Value *> MissingVals;
2750
2744
2745
+ Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock (
2746
+ OrigLoop->getLoopPreheader ()))
2747
+ ->getIncomingValueForBlock (MiddleBlock);
2748
+
2751
2749
// An external user of the last iteration's value should see the value that
2752
2750
// the remainder loop uses to initialize its own IV.
2753
2751
Value *PostInc = OrigPhi->getIncomingValueForBlock (OrigLoop->getLoopLatch ());
@@ -2951,8 +2949,8 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State,
2951
2949
// Fix-up external users of the induction variables.
2952
2950
for (const auto &Entry : Legal->getInductionVars ())
2953
2951
fixupIVUsers (Entry.first , Entry.second ,
2954
- getOrCreateVectorTripCount (nullptr ),
2955
- IVEndValues[Entry. first ], LoopMiddleBlock, Plan, State);
2952
+ getOrCreateVectorTripCount (nullptr ), LoopMiddleBlock, Plan,
2953
+ State);
2956
2954
}
2957
2955
2958
2956
for (Instruction *PI : PredicatedInstructions)
0 commit comments