Minor efficiency improvement, finegrainify namespacification
authorChris Lattner <sabre@nondot.org>
Thu, 25 Mar 2004 22:56:03 +0000 (22:56 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 25 Mar 2004 22:56:03 +0000 (22:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12517 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ValueNumbering.cpp

index 0d016f32288711a04d0c0cca2ffd35e035af4058..49b75bd6acc05b40f6ea6871ba1cb0883de01054 100644 (file)
@@ -18,8 +18,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/Type.h"
-
-namespace llvm {
+using namespace llvm;
 
 // Register the ValueNumbering interface, providing a nice name to refer to.
 static RegisterAnalysisGroup<ValueNumbering> X("Value Numbering");
@@ -177,6 +176,14 @@ static bool IdenticalComplexInst(const Instruction *I1, const Instruction *I2) {
 
 void BVNImpl::visitGetElementPtrInst(GetElementPtrInst &I) {
   Value *Op = I.getOperand(0);
+
+  // Try to pick a local operand if possible instead of a constant or a global
+  // that might have a lot of uses.
+  for (unsigned i = 1, e = I.getNumOperands(); i != e; ++i)
+    if (isa<Instruction>(I.getOperand(i)) || isa<Argument>(I.getOperand(i))) {
+      Op = I.getOperand(i);
+      break;
+    }
   
   for (Value::use_iterator UI = Op->use_begin(), UE = Op->use_end();
        UI != UE; ++UI)
@@ -188,6 +195,4 @@ void BVNImpl::visitGetElementPtrInst(GetElementPtrInst &I) {
       }
 }
 
-void BasicValueNumberingStub() { }
-
-} // End llvm namespace
+void llvm::BasicValueNumberingStub() { }