[llvm] c515b2f - [IRCE] Avoid computing potentially unnecessary analyses. NFC
Anna Thomas via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 06:22:15 PDT 2022
Author: Anna Thomas
Date: 2022-04-27T09:22:10-04:00
New Revision: c515b2f39e77f80b564e53c4c59d8c4d8bd432cf
URL: https://github.com/llvm/llvm-project/commit/c515b2f39e77f80b564e53c4c59d8c4d8bd432cf
DIFF: https://github.com/llvm/llvm-project/commit/c515b2f39e77f80b564e53c4c59d8c4d8bd432cf.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
index a83aefce9421..fbb5de7b02a9 100644
--- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -1761,10 +1761,14 @@ IntersectUnsignedRange(ScalarEvolution &SE,
}
PreservedAnalyses IRCEPass::run(Function &F, FunctionAnalysisManager &AM) {
- auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F);
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
- auto &BPI = AM.getResult<BranchProbabilityAnalysis>(F);
LoopInfo &LI = AM.getResult<LoopAnalysis>(F);
+ // There are no loops in the function. Return before computing other expensive
+ // analyses.
+ if (LI.empty())
+ return PreservedAnalyses::all();
+ auto &SE = AM.getResult<ScalarEvolutionAnalysis>(F);
+ auto &BPI = AM.getResult<BranchProbabilityAnalysis>(F);
// Get BFI analysis result on demand. Please note that modification of
// CFG invalidates this analysis and we should handle it.
More information about the llvm-commits
mailing list