[llvm-commits] [llvm] r50201 - /llvm/trunk/lib/Transforms/Scalar/SCCP.cpp

Chris Lattner sabre at nondot.org
Wed Apr 23 17:16:28 PDT 2008


Author: lattner
Date: Wed Apr 23 19:16:28 2008
New Revision: 50201

URL: http://llvm.org/viewvc/llvm-project?rev=50201&view=rev
Log:
code cleanup, no functionality change.

Modified:
    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=50201&r1=50200&r2=50201&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Wed Apr 23 19:16:28 2008
@@ -1516,25 +1516,27 @@
       //
       for (BasicBlock::iterator BI = BB->begin(), E = BB->end(); BI != E; ) {
         Instruction *Inst = BI++;
-        if (Inst->getType() != Type::VoidTy) {
-          LatticeVal &IV = Values[Inst];
-          if ((IV.isConstant() || IV.isUndefined()) &&
-              !isa<TerminatorInst>(Inst)) {
-            Constant *Const = IV.isConstant()
-              ? IV.getConstant() : UndefValue::get(Inst->getType());
-            DOUT << "  Constant: " << *Const << " = " << *Inst;
-
-            // Replaces all of the uses of a variable with uses of the constant.
-            Inst->replaceAllUsesWith(Const);
-
-            // Delete the instruction.
-            BB->getInstList().erase(Inst);
-
-            // Hey, we just changed something!
-            MadeChanges = true;
-            ++NumInstRemoved;
-          }
-        }
+        if (Inst->getType() == Type::VoidTy || 
+            isa<TerminatorInst>(Inst))
+          continue;
+        
+        LatticeVal &IV = Values[Inst];
+        if (!IV.isConstant() && !IV.isUndefined())
+          continue;
+        
+        Constant *Const = IV.isConstant()
+          ? IV.getConstant() : UndefValue::get(Inst->getType());
+        DOUT << "  Constant: " << *Const << " = " << *Inst;
+
+        // Replaces all of the uses of a variable with uses of the constant.
+        Inst->replaceAllUsesWith(Const);
+        
+        // Delete the instruction.
+        Inst->eraseFromParent();
+        
+        // Hey, we just changed something!
+        MadeChanges = true;
+        ++NumInstRemoved;
       }
     }
 





More information about the llvm-commits mailing list