Skip to content

Commit c515b2f

Browse files
committed
[IRCE] Avoid computing potentially unnecessary analyses. NFC
IRCE is a function pass that operates on loops. If there are no loops in the function (as seen through LI), we should avoid computing the remaining expensive analyses (such as BPI). Reordered the analyses requests and early return if there are no loops. This is an NFC with compile time improvement. The same will be done in a follow-up patch for the loop vectorizer. Reviewed-By: nikic Differential Revision: https://reviews.llvm.org/D124478
1 parent 70dbb5a commit c515b2f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,10 +1761,14 @@ IntersectUnsignedRange(ScalarEvolution &SE,
17611761
}
17621762

17631763
PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) {
1764-
auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F);
17651764
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
1766-
auto &BPI = AM.getResult<BranchProbabilityAnalysis>(F);
17671765
LoopInfo &LI = AM.getResult<LoopAnalysis>(F);
1766+
// There are no loops in the function. Return before computing other expensive
1767+
// analyses.
1768+
if (LI.empty())
1769+
return PreservedAnalyses::all();
1770+
auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F);
1771+
auto &BPI = AM.getResult<BranchProbabilityAnalysis>(F);
17681772

17691773
// Get BFI analysis result on demand. Please note that modification of
17701774
// CFG invalidates this analysis and we should handle it.

0 commit comments

Comments
 (0)