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

Nate Begeman natebegeman at mac.com
Thu Aug 4 16:24:32 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

CondPropagate.cpp updated: 1.3 -> 1.4
InstructionCombining.cpp updated: 1.361 -> 1.362
LoopSimplify.cpp updated: 1.56 -> 1.57
---
Log message:

Fix a fixme in CondPropagate.cpp by moving a PhiNode optimization into
BasicBlock's removePredecessor routine.  This requires shuffling around
the definition and implementation of hasContantValue from Utils.h,cpp into
Instructions.h,cpp


---
Diffs of the changes:  (+3 -15)

 CondPropagate.cpp        |   11 -----------
 InstructionCombining.cpp |    2 +-
 LoopSimplify.cpp         |    5 ++---
 3 files changed, 3 insertions(+), 15 deletions(-)


Index: llvm/lib/Transforms/Scalar/CondPropagate.cpp
diff -u llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.3 llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.4
--- llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.3	Thu Apr 21 18:45:12 2005
+++ llvm/lib/Transforms/Scalar/CondPropagate.cpp	Thu Aug  4 18:24:19 2005
@@ -80,17 +80,6 @@
       SimplifyPredecessors(SI);
   }
 
-  // See if we can fold any PHI nodes in this block now.
-  // FIXME: This would not be required if removePredecessor did this for us!!
-  PHINode *PN;
-  for (BasicBlock::iterator I = BB->begin(); (PN = dyn_cast<PHINode>(I++)); )
-    if (Value *PNV = hasConstantValue(PN))
-      if (!isa<Instruction>(PNV)) {
-        PN->replaceAllUsesWith(PNV);
-        PN->eraseFromParent();
-        MadeChange = true;
-      }
-
   // If possible, simplify the terminator of this block.
   if (ConstantFoldTerminator(BB))
     MadeChange = true;


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.361 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.362
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.361	Tue Aug  2 14:16:58 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Aug  4 18:24:19 2005
@@ -4401,7 +4401,7 @@
 // PHINode simplification
 //
 Instruction *InstCombiner::visitPHINode(PHINode &PN) {
-  if (Value *V = hasConstantValue(&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)) {


Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.56 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.57
--- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.56	Thu Apr 21 18:45:12 2005
+++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp	Thu Aug  4 18:24:19 2005
@@ -41,7 +41,6 @@
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Support/CFG.h"
-#include "llvm/Transforms/Utils/Local.h"
 #include "llvm/ADT/SetOperations.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/Statistic.h"
@@ -257,7 +256,7 @@
       PN->addIncoming(InVal, NewBB);
 
       // Can we eliminate this phi node now?
-      if (Value *V = hasConstantValue(PN)) {
+      if (Value *V = PN->hasConstantValue()) {
         if (!isa<Instruction>(V) ||
             getAnalysis<DominatorSet>().dominates(cast<Instruction>(V), PN)) {
           PN->replaceAllUsesWith(V);
@@ -443,7 +442,7 @@
   for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ) {
     PHINode *PN = cast<PHINode>(I);
     ++I;
-    if (Value *V = hasConstantValue(PN))
+    if (Value *V = PN->hasConstantValue())
       if (!isa<Instruction>(V) || DS.dominates(cast<Instruction>(V), PN)) {
         // This is a degenerate PHI already, don't modify it!
         PN->replaceAllUsesWith(V);






More information about the llvm-commits mailing list