aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-29 18:03:33 +0000
committerChris Lattner <sabre@nondot.org>2010-08-29 18:03:33 +0000
commitbb07ed3bb5db1b610362628ceb31349667c491c2 (patch)
treee6b162958d5b3f640cba62862c6b313de98af720
parent98917503c702e16f35ccdec3f6b4c48e5c4759ac (diff)
optimize LICM::hoist to use moveBefore. Correct its updating
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
-rw-r--r--lib/Transforms/Scalar/LICM.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index e6a8b2d572..a214d969e9 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -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;