Commit 9c81b57c authored by Bill Wendling's avatar Bill Wendling
Browse files

Merging r155166:

------------------------------------------------------------------------
r155166 | void | 2012-04-19 16:31:07 -0700 (Thu, 19 Apr 2012) | 1 line

Put this expensive check below the less expensive ones.
------------------------------------------------------------------------

llvm-svn: 155830
parent ee386407
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -409,15 +409,6 @@ bool LoopUnswitch::processCurrentLoop() {
  if (!currentLoop->isSafeToClone())
    return false;

  // Loops with invokes, whose unwind edge escapes the loop, cannot be
  // unswitched because splitting their edges are non-trivial and don't preserve
  // loop simplify information.
  for (Loop::block_iterator I = currentLoop->block_begin(),
         E = currentLoop->block_end(); I != E; ++I)
    if (const InvokeInst *II = dyn_cast<InvokeInst>((*I)->getTerminator()))
      if (!currentLoop->contains(II->getUnwindDest()))
        return false;

  // Without dedicated exits, splitting the exit edge may fail.
  if (!currentLoop->hasDedicatedExits())
    return false;
@@ -429,6 +420,15 @@ bool LoopUnswitch::processCurrentLoop() {
  if (!BranchesInfo.countLoop(currentLoop))
    return false;

  // Loops with invokes, whose unwind edge escapes the loop, cannot be
  // unswitched because splitting their edges are non-trivial and don't preserve
  // loop simplify information.
  for (Loop::block_iterator I = currentLoop->block_begin(),
         E = currentLoop->block_end(); I != E; ++I)
    if (const InvokeInst *II = dyn_cast<InvokeInst>((*I)->getTerminator()))
      if (!currentLoop->contains(II->getUnwindDest()))
        return false;

  // Loop over all of the basic blocks in the loop.  If we find an interior
  // block that is branching on a loop-invariant condition, we can unswitch this
  // loop.