[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Aug 4 18:04:41 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.362 -> 1.363
---
Log message:

now that hasConstantValue defaults to only returning values that dominate
the PHI node, this ugly code can vanish.


---
Diffs of the changes:  (+2 -19)

 InstructionCombining.cpp |   21 ++-------------------
 1 files changed, 2 insertions(+), 19 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.362 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.363
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.362	Thu Aug  4 18:24:19 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Aug  4 20:04:30 2005
@@ -4401,25 +4401,8 @@
 // PHINode simplification
 //
 Instruction *InstCombiner::visitPHINode(PHINode &PN) {
-  if (Value *V = PN.hasConstantValue()) {
-    // If V is an instruction, we have to be certain that it dominates PN.
-    // However, because we don't have dom info, we can't do a perfect job.
-    if (Instruction *I = dyn_cast<Instruction>(V)) {
-      // We know that the instruction dominates the PHI if there are no undef
-      // values coming in.  If the instruction is defined in the entry block,
-      // and is not an invoke, we know it is ok.
-      if (I->getParent() != &I->getParent()->getParent()->front() ||
-          isa<InvokeInst>(I))
-        for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
-          if (isa<UndefValue>(PN.getIncomingValue(i))) {
-            V = 0;
-            break;
-          }
-    }
-
-    if (V)
-      return ReplaceInstUsesWith(PN, V);
-  }
+  if (Value *V = PN.hasConstantValue())
+    return ReplaceInstUsesWith(PN, V);
 
   // If the only user of this instruction is a cast instruction, and all of the
   // incoming values are constants, change this PHI to merge together the casted






More information about the llvm-commits mailing list