Skip to content

Commit

Permalink
optimize LICM::hoist to use moveBefore. Correct its updating
Browse files Browse the repository at this point in the history
of AST to remove the hoisted instruction from the AST, since it
is no longer in the loop.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112448 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Aug 29, 2010
1 parent 9891750 commit bb07ed3
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/Transforms/Scalar/LICM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,11 @@ void LICM::hoist(Instruction &I) {
DEBUG(dbgs() << "LICM hoisting to " << Preheader->getName() << ": "
<< I << "\n");

// Remove the instruction from its current basic block... but don't delete the
// instruction.
I.removeFromParent();

// Insert the new node in Preheader, before the terminator.
Preheader->getInstList().insert(Preheader->getTerminator(), &I);
// The instruction is no longer in this loop.
CurAST->deleteValue(&I);

// Move the new node to the Preheader, before its terminator.
I.moveBefore(Preheader->getTerminator());

if (isa<LoadInst>(I)) ++NumMovedLoads;
else if (isa<CallInst>(I)) ++NumMovedCalls;
Expand Down

0 comments on commit bb07ed3

Please sign in to comment.