[llvm-commits] [poolalloc] r156461 - in /poolalloc/trunk/lib: AssistDS/SimplifyInsertValue.cpp AssistDS/SimplifyLoad.cpp AssistDS/TypeChecks.cpp DSA/Local.cpp

Will Dietz wdietz2 at illinois.edu
Tue May 8 21:30:29 PDT 2012


Author: wdietz2
Date: Tue May  8 23:30:29 2012
New Revision: 156461

URL: http://llvm.org/viewvc/llvm-project?rev=156461&view=rev
Log:
Use Value::hasOneUse() where we can, surprisingly helps a good deal.

(Less surprising once you see getNumUses is linear, but still)

Local on 403.gcc was 27s (hence getting attention), now it's 3s.

In fact, just changing the getNumUses in visitStoreInst did the trick,
   but might as well replace this everywhere while we're at it.

Modified:
    poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp
    poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp
    poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
    poolalloc/trunk/lib/DSA/Local.cpp

Modified: poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp?rev=156461&r1=156460&r2=156461&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp Tue May  8 23:30:29 2012
@@ -60,7 +60,7 @@
           if(!IV)
             continue;
           // Find all insert value instructions.
-          if(IV->getNumUses() != 1)
+          if(!IV->hasOneUse())
             continue;
           // Check that its only use is a StoreInst
           StoreInst *SI = dyn_cast<StoreInst>(*(IV->use_begin()));

Modified: poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp?rev=156461&r1=156460&r2=156461&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/SimplifyLoad.cpp Tue May  8 23:30:29 2012
@@ -56,7 +56,7 @@
           LoadInst *LI = dyn_cast<LoadInst>(I++);
           if(!LI)
             continue;
-          if(LI->getNumUses() == 1) {
+          if(LI->hasOneUse()) {
             if(CastInst *CI = dyn_cast<CastInst>(*(LI->use_begin()))) {
               if(LI->getType()->isPointerTy()) {
                 if(ConstantExpr *CE = dyn_cast<ConstantExpr>(LI->getOperand(0))) {

Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=156461&r1=156460&r2=156461&view=diff
==============================================================================
--- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original)
+++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue May  8 23:30:29 2012
@@ -2105,7 +2105,7 @@
   }
   visitUses(&LI, AI, BCI);
 
-  if(AI->getNumUses() == 1) {
+  if(AI->hasOneUse()) {
     // No uses needed checks
     getTypeCall->eraseFromParent();
   }

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=156461&r1=156460&r2=156461&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue May  8 23:30:29 2012
@@ -390,7 +390,7 @@
 
   // check that it is the inserted value
   if(TypeInferenceOptimize)
-    if(LI.getNumUses() == 1) 
+    if(LI.hasOneUse())
       if(StoreInst *SI = dyn_cast<StoreInst>(*(LI.use_begin())))
         if(SI->getOperand(0) == &LI) {
         ++NumIgnoredInst;
@@ -415,7 +415,7 @@
     Dest.addEdgeTo(getValueDest(SI.getOperand(0)));
 
   if(TypeInferenceOptimize)
-    if(SI.getOperand(0)->getNumUses() == 1)
+    if(SI.getOperand(0)->hasOneUse())
       if(isa<LoadInst>(SI.getOperand(0))){
         ++NumIgnoredInst;
         return;
@@ -550,7 +550,7 @@
 
 void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) {
   DSNode *N = createNode();
-  if(I.getNumUses() == 1) {
+  if(I.hasOneUse()) {
     if(isa<ICmpInst>(*(I.use_begin()))) {
       NumBoringIntToPtr++;
       return;
@@ -564,16 +564,16 @@
 
 void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) {
   DSNode* N = getValueDest(I.getOperand(0)).getNode();
-  if(I.getNumUses() == 1) {
+  if(I.hasOneUse()) {
     if(isa<ICmpInst>(*(I.use_begin()))) {
       NumBoringIntToPtr++;
       return;
     }
   }
-  if(I.getNumUses() == 1) {
+  if(I.hasOneUse()) {
     Value *V = dyn_cast<Value>(*(I.use_begin()));
     DenseSet<Value *> Seen;
-    while(V && V->getNumUses() == 1 &&
+    while(V && V->hasOneUse() &&
           Seen.insert(V).second) {
       if(isa<LoadInst>(V))
         break;





More information about the llvm-commits mailing list