[llvm-commits] [llvm] r80170 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Wed Aug 26 15:55:11 PDT 2009


Author: resistor
Date: Wed Aug 26 17:55:11 2009
New Revision: 80170

URL: http://llvm.org/viewvc/llvm-project?rev=80170&view=rev
Log:
Make this into a static method.

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

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

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Aug 26 17:55:11 2009
@@ -730,10 +730,8 @@
     void dump(DenseMap<uint32_t, Value*>& d);
     bool iterateOnFunction(Function &F);
     Value* CollapsePhi(PHINode* p);
-    bool isSafeReplacement(PHINode* p, Instruction* inst);
     bool performPRE(Function& F);
     Value* lookupNumber(BasicBlock* BB, uint32_t num);
-    bool mergeBlockIntoPredecessor(BasicBlock* BB);
     Value* AttemptRedundancyElimination(Instruction* orig, unsigned valno);
     void cleanupGlobalSets();
     void verifyRemoved(const Instruction *I) const;
@@ -758,6 +756,19 @@
   printf("}\n");
 }
 
+static bool isSafeReplacement(PHINode* p, Instruction* inst) {
+  if (!isa<PHINode>(inst))
+    return true;
+  
+  for (Instruction::use_iterator UI = p->use_begin(), E = p->use_end();
+       UI != E; ++UI)
+    if (PHINode* use_phi = dyn_cast<PHINode>(UI))
+      if (use_phi->getParent() == inst->getParent())
+        return false;
+  
+  return true;
+}
+
 Value* GVN::CollapsePhi(PHINode* p) {
   Value* constVal = p->hasConstantValue();
   if (!constVal) return 0;
@@ -772,19 +783,6 @@
   return 0;
 }
 
-bool GVN::isSafeReplacement(PHINode* p, Instruction* inst) {
-  if (!isa<PHINode>(inst))
-    return true;
-  
-  for (Instruction::use_iterator UI = p->use_begin(), E = p->use_end();
-       UI != E; ++UI)
-    if (PHINode* use_phi = dyn_cast<PHINode>(UI))
-      if (use_phi->getParent() == inst->getParent())
-        return false;
-  
-  return true;
-}
-
 /// GetValueForBlock - Get the value to use within the specified basic block.
 /// available values are in Phis.
 Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,





More information about the llvm-commits mailing list