[PATCH] Make ScalarEvolution::ComputeExitLimit more agressive

hfinkel at anl.gov hfinkel at anl.gov
Tue Jan 27 19:00:43 PST 2015


================
Comment at: lib/Analysis/ScalarEvolution.cpp:4820
@@ +4819,3 @@
+  auto DominatesHeaderIgnoringLoopEntry = [L](BasicBlock *BB) {
+    // We follow the chain of unique predecessors and successors from BB until
+    // we reach the header.  The header is allowed to have predecessors other
----------------
There really should not be any non-trivial "chains" of blocks with unique predecessors and successors once SimplifyCFG has run (as I understand it). What motivates this?


================
Comment at: lib/Analysis/ScalarEvolution.cpp:4827
@@ +4826,3 @@
+    while (true) {
+      if (std::next(pred_begin(UniqueSucc)) != pred_end(UniqueSucc))
+        return false;
----------------
This needs a comment. Why are you bailing out if there is more than one predecessor?

================
Comment at: lib/Analysis/ScalarEvolution.cpp:4844
@@ +4843,3 @@
+                       });
+  };
+
----------------
In conclusion, I think this function is both overly limiting and too complicated (it handles a chain case that should not really occur -- although I certainly could be wrong about this).

It is also not quite correct (because you also need to check that none of these blocks have functions that might throw).

I think that a direct general approach would be better. Just walk the predecessor graph starting at BB, bailing out if you hit an edge that leaves the loop, and stopping when you hit the loop header. You also need to check for functions that might throw (this is what LICM does).

http://reviews.llvm.org/D6830

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list