Loop invariant code motion now depends on the LoopPreheader pass. Dead code
authorChris Lattner <sabre@nondot.org>
Thu, 26 Sep 2002 16:19:31 +0000 (16:19 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Sep 2002 16:19:31 +0000 (16:19 +0000)
has not yet been removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3945 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LICM.cpp

index 7bae9fd18a5a5b7ff8167f3f3b521c3d5cf8e7b6..f67fa6c6495f55770a8fbc506090932303366e0d 100644 (file)
@@ -42,6 +42,7 @@ namespace {
     // This transformation requires natural loop information...
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.preservesCFG();
+      AU.addRequiredID(LoopPreheadersID);
       AU.addRequired<LoopInfo>();
       AU.addRequired<AliasAnalysis>();
     }
@@ -104,11 +105,7 @@ namespace {
     }
     void visitShiftInst(ShiftInst &I) { visitBinaryOperator((Instruction&)I); }
 
-    void visitLoadInst(LoadInst &LI) {
-      if (isLoopInvariant(LI.getOperand(0)) &&
-          !pointerInvalidatedByLoop(LI.getOperand(0)))
-        hoist(LI);
-    }
+    void visitLoadInst(LoadInst &LI);
 
     void visitGetElementPtrInst(GetElementPtrInst &GEPI) {
       Instruction &I = (Instruction&)GEPI;
@@ -276,6 +273,14 @@ void LICM::hoist(Instruction &Inst) {
   Changed = true;
 }
 
+
+void LICM::visitLoadInst(LoadInst &LI) {
+  if (isLoopInvariant(LI.getOperand(0)) &&
+      !pointerInvalidatedByLoop(LI.getOperand(0)))
+    hoist(LI);
+
+}
+
 // pointerInvalidatedByLoop - Return true if the body of this loop may store
 // into the memory location pointed to by V.
 //