[PATCH] D124478: [IRCE] Avoid computing potentially unnecessary analyses. NFC

Anna Thomas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 14:27:29 PDT 2022


anna created this revision.
anna added reviewers: mkazantsev, asbirlea.
Herald added a subscriber: hiraditya.
Herald added a project: All.
anna requested review of this revision.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124478

Files:
  llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp


Index: llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -1761,10 +1761,14 @@
 }
 
 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124478.425305.patch
Type: text/x-patch
Size: 1000 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220426/39c2dc28/attachment.bin>


More information about the llvm-commits mailing list