@@ -505,9 +505,6 @@ class InnerLoopVectorizer {
505
505
// / Fix the vectorized code, taking care of header phi's, and more.
506
506
void fixVectorizedLoop (VPTransformState &State);
507
507
508
- // Return true if any runtime check is added.
509
- bool areSafetyChecksAdded () { return AddedSafetyChecks; }
510
-
511
508
// / Fix the non-induction PHIs in \p Plan.
512
509
void fixNonInductionPHIs (VPTransformState &State);
513
510
@@ -620,9 +617,6 @@ class InnerLoopVectorizer {
620
617
// / The profitablity analysis.
621
618
LoopVectorizationCostModel *Cost;
622
619
623
- // Record whether runtime checks are added.
624
- bool AddedSafetyChecks = false ;
625
-
626
620
// / BFI and PSI are used to check for profile guided size optimizations.
627
621
BlockFrequencyInfo *BFI;
628
622
ProfileSummaryInfo *PSI;
@@ -1777,6 +1771,9 @@ class GeneratedRTChecks {
1777
1771
// / they have been used.
1778
1772
Value *MemRuntimeCheckCond = nullptr ;
1779
1773
1774
+ // / True if any checks have been added.
1775
+ bool AddedAnyChecks = false ;
1776
+
1780
1777
DominatorTree *DT;
1781
1778
LoopInfo *LI;
1782
1779
TargetTransformInfo *TTI;
@@ -2038,9 +2035,9 @@ class GeneratedRTChecks {
2038
2035
if (AddBranchWeights)
2039
2036
setBranchWeights (BI, SCEVCheckBypassWeights, /* IsExpected=*/ false );
2040
2037
ReplaceInstWithInst (SCEVCheckBlock->getTerminator (), &BI);
2041
-
2042
2038
// Mark the check as used, to prevent it from being removed during cleanup.
2043
2039
SCEVCheckCond = nullptr ;
2040
+ AddedAnyChecks = true ;
2044
2041
return SCEVCheckBlock;
2045
2042
}
2046
2043
@@ -2070,8 +2067,12 @@ class GeneratedRTChecks {
2070
2067
2071
2068
// Mark the check as used, to prevent it from being removed during cleanup.
2072
2069
MemRuntimeCheckCond = nullptr ;
2070
+ AddedAnyChecks = true ;
2073
2071
return MemCheckBlock;
2074
2072
}
2073
+
2074
+ // / Return true if any runtime checks have been added
2075
+ bool hasChecks () const { return AddedAnyChecks; }
2075
2076
};
2076
2077
} // namespace
2077
2078
@@ -2459,7 +2460,6 @@ BasicBlock *InnerLoopVectorizer::emitSCEVChecks(BasicBlock *Bypass) {
2459
2460
assert ((!Cost->OptForSize ||
2460
2461
Cost->Hints ->getForce () == LoopVectorizeHints::FK_Enabled) &&
2461
2462
" Cannot SCEV check stride or overflow when optimizing for size" );
2462
- AddedSafetyChecks = true ;
2463
2463
2464
2464
introduceCheckBlockInVPlan (SCEVCheckBlock);
2465
2465
return SCEVCheckBlock;
@@ -2494,9 +2494,6 @@ BasicBlock *InnerLoopVectorizer::emitMemRuntimeChecks(BasicBlock *Bypass) {
2494
2494
});
2495
2495
}
2496
2496
2497
-
2498
- AddedSafetyChecks = true ;
2499
-
2500
2497
introduceCheckBlockInVPlan (MemCheckBlock);
2501
2498
return MemCheckBlock;
2502
2499
}
@@ -10287,7 +10284,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10287
10284
}
10288
10285
++LoopsEpilogueVectorized;
10289
10286
10290
- if (!MainILV. areSafetyChecksAdded ())
10287
+ if (!Checks. hasChecks ())
10291
10288
DisableRuntimeUnroll = true ;
10292
10289
} else {
10293
10290
InnerLoopVectorizer LB (L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width ,
@@ -10299,7 +10296,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
10299
10296
// Add metadata to disable runtime unrolling a scalar loop when there
10300
10297
// are no runtime checks about strides and memory. A scalar loop that is
10301
10298
// rarely used is not worth unrolling.
10302
- if (!LB. areSafetyChecksAdded ())
10299
+ if (!Checks. hasChecks ())
10303
10300
DisableRuntimeUnroll = true ;
10304
10301
}
10305
10302
// Report the vectorization decision.
0 commit comments