@@ -505,9 +505,6 @@ class InnerLoopVectorizer {
505505 // / Fix the vectorized code, taking care of header phi's, and more.
506506 void fixVectorizedLoop (VPTransformState &State);
507507
508- // Return true if any runtime check is added.
509- bool areSafetyChecksAdded () { return AddedSafetyChecks; }
510-
511508 // / Fix the non-induction PHIs in \p Plan.
512509 void fixNonInductionPHIs (VPTransformState &State);
513510
@@ -620,9 +617,6 @@ class InnerLoopVectorizer {
620617 // / The profitablity analysis.
621618 LoopVectorizationCostModel *Cost;
622619
623- // Record whether runtime checks are added.
624- bool AddedSafetyChecks = false ;
625-
626620 // / BFI and PSI are used to check for profile guided size optimizations.
627621 BlockFrequencyInfo *BFI;
628622 ProfileSummaryInfo *PSI;
@@ -1777,6 +1771,9 @@ class GeneratedRTChecks {
17771771 // / they have been used.
17781772 Value *MemRuntimeCheckCond = nullptr ;
17791773
1774+ // / True if any checks have been added.
1775+ bool AddedAnyChecks = false ;
1776+
17801777 DominatorTree *DT;
17811778 LoopInfo *LI;
17821779 TargetTransformInfo *TTI;
@@ -2038,9 +2035,9 @@ class GeneratedRTChecks {
20382035 if (AddBranchWeights)
20392036 setBranchWeights (BI, SCEVCheckBypassWeights, /* IsExpected=*/ false );
20402037 ReplaceInstWithInst (SCEVCheckBlock->getTerminator (), &BI);
2041-
20422038 // Mark the check as used, to prevent it from being removed during cleanup.
20432039 SCEVCheckCond = nullptr ;
2040+ AddedAnyChecks = true ;
20442041 return SCEVCheckBlock;
20452042 }
20462043
@@ -2070,8 +2067,12 @@ class GeneratedRTChecks {
20702067
20712068 // Mark the check as used, to prevent it from being removed during cleanup.
20722069 MemRuntimeCheckCond = nullptr ;
2070+ AddedAnyChecks = true ;
20732071 return MemCheckBlock;
20742072 }
2073+
2074+ // / Return true if any runtime checks have been added
2075+ bool hasChecks () const { return AddedAnyChecks; }
20752076};
20762077} // namespace
20772078
@@ -2459,7 +2460,6 @@ BasicBlock *InnerLoopVectorizer::emitSCEVChecks(BasicBlock *Bypass) {
24592460 assert ((!Cost->OptForSize ||
24602461 Cost->Hints ->getForce () == LoopVectorizeHints::FK_Enabled) &&
24612462 " Cannot SCEV check stride or overflow when optimizing for size" );
2462- AddedSafetyChecks = true ;
24632463
24642464 introduceCheckBlockInVPlan (SCEVCheckBlock);
24652465 return SCEVCheckBlock;
@@ -2494,9 +2494,6 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(BasicBlock *Bypass) {
24942494 });
24952495 }
24962496
2497-
2498- AddedSafetyChecks = true ;
2499-
25002497 introduceCheckBlockInVPlan (MemCheckBlock);
25012498 return MemCheckBlock;
25022499}
@@ -10287,7 +10284,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1028710284 }
1028810285 ++LoopsEpilogueVectorized;
1028910286
10290- if (!MainILV. areSafetyChecksAdded ())
10287+ if (!Checks. hasChecks ())
1029110288 DisableRuntimeUnroll = true ;
1029210289 } else {
1029310290 InnerLoopVectorizer LB (L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width ,
@@ -10299,7 +10296,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1029910296 // Add metadata to disable runtime unrolling a scalar loop when there
1030010297 // are no runtime checks about strides and memory. A scalar loop that is
1030110298 // rarely used is not worth unrolling.
10302- if (!LB. areSafetyChecksAdded ())
10299+ if (!Checks. hasChecks ())
1030310300 DisableRuntimeUnroll = true ;
1030410301 }
1030510302 // Report the vectorization decision.
0 commit comments