@@ -537,8 +537,8 @@ class InnerLoopVectorizer {
537
537
538
538
// / Set up the values of the IVs correctly when exiting the vector loop.
539
539
virtual void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II,
540
- Value *VectorTripCount, Value *EndValue ,
541
- BasicBlock *MiddleBlock, VPTransformState &State);
540
+ Value *VectorTripCount, BasicBlock *MiddleBlock ,
541
+ VPTransformState &State);
542
542
543
543
// / Iteratively sink the scalarized operands of a predicated instruction into
544
544
// / the block that was created for it.
@@ -651,10 +651,6 @@ class InnerLoopVectorizer {
651
651
// Record whether runtime checks are added.
652
652
bool AddedSafetyChecks = false ;
653
653
654
- // Holds the end values for each induction variable. We save the end values
655
- // so we can later fix-up the external users of the induction variables.
656
- DenseMap<PHINode *, Value *> IVEndValues;
657
-
658
654
// / BFI and PSI are used to check for profile guided size optimizations.
659
655
BlockFrequencyInfo *BFI;
660
656
ProfileSummaryInfo *PSI;
@@ -766,8 +762,7 @@ class EpilogueVectorizerMainLoop : public InnerLoopAndEpilogueVectorizer {
766
762
void printDebugTracesAtEnd () override ;
767
763
768
764
void fixupIVUsers (PHINode *OrigPhi, const InductionDescriptor &II,
769
- Value *VectorTripCount, Value *EndValue,
770
- BasicBlock *MiddleBlock,
765
+ Value *VectorTripCount, BasicBlock *MiddleBlock,
771
766
VPTransformState &State) override {};
772
767
};
773
768
@@ -2599,7 +2594,7 @@ PHINode *InnerLoopVectorizer::createInductionResumeValue(
2599
2594
assert (VectorTripCount && " Expected valid arguments" );
2600
2595
2601
2596
Instruction *OldInduction = Legal->getPrimaryInduction ();
2602
- Value *& EndValue = IVEndValues[OrigPhi] ;
2597
+ Value *EndValue = nullptr ;
2603
2598
Value *EndValueFromAdditionalBypass = AdditionalBypass.second ;
2604
2599
if (OrigPhi == OldInduction) {
2605
2600
// We know what the end value is.
@@ -2756,7 +2751,7 @@ InnerLoopVectorizer::createVectorizedLoopSkeleton(
2756
2751
// value for the IV when arriving directly from the middle block.
2757
2752
void InnerLoopVectorizer::fixupIVUsers (PHINode *OrigPhi,
2758
2753
const InductionDescriptor &II,
2759
- Value *VectorTripCount, Value *EndValue,
2754
+ Value *VectorTripCount,
2760
2755
BasicBlock *MiddleBlock,
2761
2756
VPTransformState &State) {
2762
2757
// There are two kinds of external IV usages - those that use the value
@@ -2768,6 +2763,10 @@ void InnerLoopVectorizer::fixupIVUsers(PHINode *OrigPhi,
2768
2763
2769
2764
DenseMap<Value *, Value *> MissingVals;
2770
2765
2766
+ Value *EndValue = cast<PHINode>(OrigPhi->getIncomingValueForBlock (
2767
+ OrigLoop->getLoopPreheader ()))
2768
+ ->getIncomingValueForBlock (MiddleBlock);
2769
+
2771
2770
// An external user of the last iteration's value should see the value that
2772
2771
// the remainder loop uses to initialize its own IV.
2773
2772
Value *PostInc = OrigPhi->getIncomingValueForBlock (OrigLoop->getLoopLatch ());
@@ -2970,8 +2969,7 @@ void InnerLoopVectorizer::fixVectorizedLoop(VPTransformState &State) {
2970
2969
// Fix-up external users of the induction variables.
2971
2970
for (const auto &Entry : Legal->getInductionVars ())
2972
2971
fixupIVUsers (Entry.first , Entry.second ,
2973
- getOrCreateVectorTripCount (nullptr ),
2974
- IVEndValues[Entry.first ], LoopMiddleBlock, State);
2972
+ getOrCreateVectorTripCount (nullptr ), LoopMiddleBlock, State);
2975
2973
}
2976
2974
2977
2975
for (Instruction *PI : PredicatedInstructions)
0 commit comments