[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp

Chris Lattner sabre at nondot.org
Fri Apr 13 17:18:00 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

CodeGenPrepare.cpp updated: 1.4 -> 1.5
---
Log message:

use an accessor to simplify code.


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

 CodeGenPrepare.cpp |   16 +---------------
 1 files changed, 1 insertion(+), 15 deletions(-)


Index: llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
diff -u llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp:1.4 llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp:1.5
--- llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp:1.4	Fri Apr 13 15:30:56 2007
+++ llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp	Fri Apr 13 19:17:39 2007
@@ -886,21 +886,7 @@
                                             SI->getOperand(0)->getType(),
                                             SunkAddrs);
     } else if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
-      bool HasNonZeroIdx = false;
-      for (GetElementPtrInst::op_iterator OI = GEPI->op_begin()+1,
-           E = GEPI->op_end(); OI != E; ++OI) {
-        if (ConstantInt *CI = dyn_cast<ConstantInt>(*OI)) {
-          if (!CI->isZero()) {
-            HasNonZeroIdx = true;
-            break;
-          }
-        } else {
-          HasNonZeroIdx = true;
-          break;
-        }
-      }
-      
-      if (!HasNonZeroIdx) {
+      if (GEPI->hasAllZeroIndices()) {
         /// The GEP operand must be a pointer, so must its result -> BitCast
         Instruction *NC = new BitCastInst(GEPI->getOperand(0), GEPI->getType(), 
                                           GEPI->getName(), GEPI);






More information about the llvm-commits mailing list