@@ -542,8 +542,8 @@ class InnerLoopVectorizer {
542
542
543
543
// / Set up the values of the IVs correctly when exiting the vector loop.
544
544
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);
547
547
548
548
// / Iteratively sink the scalarized operands of a predicated instruction into
549
549
// / the block that was created for it.
@@ -656,10 +656,6 @@ class InnerLoopVectorizer {
656
656
// Record whether runtime checks are added.
657
657
bool AddedSafetyChecks = false ;
658
658
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
-
663
659
// / BFI and PSI are used to check for profile guided size optimizations.
664
660
BlockFrequencyInfo *BFI;
665
661
ProfileSummaryInfo *PSI;
@@ -774,8 +770,7 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
774
770
void printDebugTracesAtEnd () override ;
775
771
776
772
void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II,
777
- Value *VectorTripCount, Value *EndValue,
778
- BasicBlock *MiddleBlock,
773
+ Value *VectorTripCount, BasicBlock *MiddleBlock,
779
774
VPTransformState &State) override {};
780
775
};
781
776
@@ -2607,7 +2602,7 @@ void InnerLoopVectorizer::createInductionResumeValue(
2607
2602
assert (VectorTripCount && " Expected valid arguments" );
2608
2603
2609
2604
Instruction *OldInduction = Legal->getPrimaryInduction ();
2610
- Value *& EndValue = IVEndValues[OrigPhi] ;
2605
+ Value *EndValue = nullptr ;
2611
2606
Value *EndValueFromAdditionalBypass = AdditionalBypass.second ;
2612
2607
if (OrigPhi == OldInduction) {
2613
2608
// We know what the end value is.
@@ -2759,7 +2754,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
2759
2754
// value for the IV when arriving directly from the middle block.
2760
2755
void InnerLoopVectorizer::fixupIVUsers (PHINode *OrigPhi,
2761
2756
const InductionDescriptor &II,
2762
- Value *VectorTripCount, Value *EndValue,
2757
+ Value *VectorTripCount,
2763
2758
BasicBlock *MiddleBlock,
2764
2759
VPTransformState &State) {
2765
2760
// There are two kinds of external IV usages - those that use the value
@@ -2771,6 +2766,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
2771
2766
2772
2767
DenseMap<Value *, Value *> MissingVals;
2773
2768
2769
+ Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock (
2770
+ OrigLoop->getLoopPreheader ()))
2771
+ ->getIncomingValueForBlock (MiddleBlock);
2772
+
2774
2773
// An external user of the last iteration's value should see the value that
2775
2774
// the remainder loop uses to initialize its own IV.
2776
2775
Value *PostInc = OrigPhi->getIncomingValueForBlock (OrigLoop->getLoopLatch ());
@@ -2973,8 +2972,8 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
2973
2972
// Fix-up external users of the induction variables.
2974
2973
for (const auto &Entry : Legal->getInductionVars ())
2975
2974
fixupIVUsers (Entry.first , Entry.second ,
2976
- getOrCreateVectorTripCount (nullptr ),
2977
- IVEndValues[Entry. first ], LoopMiddleBlock, State);
2975
+ getOrCreateVectorTripCount (nullptr ), LoopMiddleBlock,
2976
+ State);
2978
2977
}
2979
2978
2980
2979
for (Instruction *PI : PredicatedInstructions)
0 commit comments