[llvm-commits] [llvm] r69752 - /llvm/trunk/lib/Transforms/Utils/InlineCost.cpp

Chris Lattner sabre at nondot.org
Tue Apr 21 16:37:18 PDT 2009


Author: lattner
Date: Tue Apr 21 18:37:18 2009
New Revision: 69752

URL: http://llvm.org/viewvc/llvm-project?rev=69752&view=rev
Log:
use predicate instead of hand-rolled loop

Modified:
    llvm/trunk/lib/Transforms/Utils/InlineCost.cpp

Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=69752&r1=69751&r2=69752&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Tue Apr 21 18:37:18 2009
@@ -76,10 +76,8 @@
       Reduction += 10;
     else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(I)) {
       // If the GEP has variable indices, we won't be able to do much with it.
-      for (Instruction::op_iterator I = GEP->op_begin()+1, E = GEP->op_end();
-           I != E; ++I)
-        if (!isa<Constant>(*I)) return 0;
-      Reduction += CountCodeReductionForAlloca(GEP)+15;
+      if (!GEP->hasAllConstantIndices())
+        Reduction += CountCodeReductionForAlloca(GEP)+15;
     } else {
       // If there is some other strange instruction, we're not going to be able
       // to do much if we inline this.
@@ -143,13 +141,8 @@
                  dyn_cast<GetElementPtrInst>(II)) {
         // If a GEP has all constant indices, it will probably be folded with
         // a load/store.
-        bool AllConstant = true;
-        for (unsigned i = 1, e = GEPI->getNumOperands(); i != e; ++i)
-          if (!isa<ConstantInt>(GEPI->getOperand(i))) {
-            AllConstant = false;
-            break;
-          }
-        if (AllConstant) continue;
+        if (GEPI->hasAllConstantIndices())
+          continue;
       }
       
       ++NumInsts;





More information about the llvm-commits mailing list