[llvm-commits] Patch to improve loop-simplify

Chris Lattner clattner at apple.com
Wed Mar 2 22:26:16 PST 2011


On Mar 2, 2011, at 10:21 PM, Andrew Clinton wrote:

> This patch improves the loop-simplify pass by avoiding the separation
> of inner/outer loops in cases where the pass can determine that the
> new outer loop would have no loop exits that are not also contained in
> the inner loop.  In this case, what appeared to be a nested loop is
> really just conditional control flow within a loop.
> 
> If someone could review and commit the patch that would be much appreciated.

Hi Andrew,

Some minor coding standards stuff:

+  std::set<BasicBlock*> BlocksInL;

set is really slow, please use SmallPtrSet<> if appropriate.  ProgrammersManual.html has a discussion about various datastructures and their tradeoffs.  I know this isn't new, but please fix :)

+      BasicBlock  *P = PN->getIncomingBlock(i);

only one space before *.


+  bool  OuterLoopHasExit = false;
+  for (unsigned i = 0; i < ExitingBlocks.size(); ++i)
+  {
+    if (!BlocksInL.count(ExitingBlocks[i]))
+    {
+      OuterLoopHasExit = true;
+      break;
+    }
+  }
+  if (!OuterLoopHasExit)
+    return 0;

Only one space after bool, please don't execute ExitingBlocks.size() every time through the loop and please put { on the preceding lines.  Cameron, can you review the algorithmic changes?

-Chris



More information about the llvm-commits mailing list