[PATCH] D124439: [JumpThreading][NFC] Reuse existing LoopInfo instead of recomputation

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 01:05:03 PDT 2022


mkazantsev created this revision.
mkazantsev added reviewers: nikic, lebedev.ri, fhahn, hans, paquette.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mkazantsev requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

There is no need to recompute DT and LI from scratch when we can reuse
existing analyzes results. CompileTime saving happens because:

- DT is always available at this point;
- LI might be available from prior loop passes.


https://reviews.llvm.org/D124439

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


Index: llvm/lib/Transforms/Scalar/JumpThreading.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -324,9 +324,9 @@
   std::unique_ptr<BlockFrequencyInfo> BFI;
   std::unique_ptr<BranchProbabilityInfo> BPI;
   if (F.hasProfileData()) {
-    LoopInfo LI{DominatorTree(F)};
-    BPI.reset(new BranchProbabilityInfo(F, LI, TLI));
-    BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
+    auto LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+    BPI.reset(new BranchProbabilityInfo(F, *LI, TLI));
+    BFI.reset(new BlockFrequencyInfo(F, *BPI, *LI));
   }
 
   bool Changed = Impl.runImpl(F, TLI, TTI, LVI, AA, &DTU, F.hasProfileData(),
@@ -353,7 +353,7 @@
   std::unique_ptr<BlockFrequencyInfo> BFI;
   std::unique_ptr<BranchProbabilityInfo> BPI;
   if (F.hasProfileData()) {
-    LoopInfo LI{DominatorTree(F)};
+    auto &LI = AM.getResult<LoopAnalysis>(F);
     BPI.reset(new BranchProbabilityInfo(F, LI, &TLI));
     BFI.reset(new BlockFrequencyInfo(F, *BPI, LI));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124439.425142.patch
Type: text/x-patch
Size: 1101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220426/5d8075fb/attachment.bin>


More information about the llvm-commits mailing list