[PATCH] D19950: Use frequency info to guide Loop Invariant Code Motion.

Jun Bum Lim via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 10:16:26 PDT 2016


junbuml added inline comments.

================
Comment at: include/llvm/Transforms/Utils/LoopUtils.h:354-360
@@ -352,8 +353,9 @@
 
 /// \brief Walk the specified region of the CFG (defined by all blocks
 /// dominated by the specified block, and that are in the current loop) in depth
 /// first order w.r.t the DominatorTree.  This allows us to visit definitions
 /// before uses, allowing us to hoist a loop body in one pass without iteration.
 /// Takes DomTreeNode, AliasAnalysis, LoopInfo, DominatorTree, DataLayout,
 /// TargetLibraryInfo, Loop, AliasSet information for all instructions of the
 /// loop and loop safety information as arguments. It returns changed status.
+bool hoistRegion(DomTreeNode *, AliasAnalysis *, LoopInfo *,
----------------
Please update the comment.

================
Comment at: lib/Transforms/Scalar/LICM.cpp:353-355
@@ -346,3 +352,5 @@
   bool Changed = false;
-  if (!inSubLoop(BB, CurLoop, LI))
+  if (!inSubLoop(BB, CurLoop, LI)) {
+    bool ShouldHoist =
+        BFI->getBlockFreq(BB) >= BFI->getBlockFreq(CurLoop->getLoopPreheader());
     for (BasicBlock::iterator II = BB->begin(), E = BB->end(); II != E;) {
----------------
I agree that we still need to perform constant folding even when ShouldHoist is false?


http://reviews.llvm.org/D19950





More information about the llvm-commits mailing list