[llvm-commits] [llvm] r112451 - in /llvm/trunk: lib/Transforms/Scalar/LICM.cpp test/Transforms/LICM/sinking.ll
Chris Lattner
sabre at nondot.org
Sun Aug 29 11:22:25 PDT 2010
Author: lattner
Date: Sun Aug 29 13:22:25 2010
New Revision: 112451
URL: http://llvm.org/viewvc/llvm-project?rev=112451&view=rev
Log:
LICM does get dead instructions input to it. Instead of sinking them
out of loops, just delete them.
Modified:
llvm/trunk/lib/Transforms/Scalar/LICM.cpp
llvm/trunk/test/Transforms/LICM/sinking.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=112451&r1=112450&r2=112451&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Sun Aug 29 13:22:25 2010
@@ -43,6 +43,7 @@
#include "llvm/Analysis/AliasSetTracker.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/ScalarEvolution.h"
+#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/SSAUpdater.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
@@ -299,7 +300,7 @@
// If this subregion is not in the top level loop at all, exit.
if (!CurLoop->contains(BB)) return;
- // We are processing blocks in reverse dfo, so process children first...
+ // We are processing blocks in reverse dfo, so process children first.
const std::vector<DomTreeNode*> &Children = N->getChildren();
for (unsigned i = 0, e = Children.size(); i != e; ++i)
SinkRegion(Children[i]);
@@ -310,6 +311,16 @@
for (BasicBlock::iterator II = BB->end(); II != BB->begin(); ) {
Instruction &I = *--II;
+
+ // If the instruction is dead, we would try to sink it because it isn't used
+ // in the loop, instead, just delete it.
+ if (isInstructionTriviallyDead(&I)) {
+ ++II;
+ CurAST->deleteValue(&I);
+ I.eraseFromParent();
+ Changed = true;
+ continue;
+ }
// Check to see if we can sink this instruction to the exit blocks
// of the loop. We can do this if the all users of the instruction are
Modified: llvm/trunk/test/Transforms/LICM/sinking.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LICM/sinking.ll?rev=112451&r1=112450&r2=112451&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LICM/sinking.ll (original)
+++ llvm/trunk/test/Transforms/LICM/sinking.ll Sun Aug 29 13:22:25 2010
@@ -233,3 +233,17 @@
; CHECK-NEXT: ret i32 %tmp.6
}
+; Should delete, not sink, dead instructions.
+define void @test11() {
+ br label %Loop
+Loop:
+ %dead = getelementptr %Ty* @X2, i64 0, i32 0
+ br i1 false, label %Loop, label %Out
+Out:
+ ret void
+; CHECK: @test11
+; CHECK: Out:
+; CHECK-NEXT: ret void
+}
+
+
More information about the llvm-commits
mailing list