Implement new helper methods for creating two-index GEP instructions
[oota-llvm.git] / lib / Transforms / LevelRaise.cpp
index edc42b7a56c650bd0e128477bc19c78c68f62230..f3a42365f060a7c7b0347c1df25dec53b96d0151 100644 (file)
@@ -370,9 +370,8 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
           // Build the index vector, full of all zeros
           std::vector<Value*> Indices;
 
-          Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); // FIXME, PR82
+          Indices.push_back(Constant::getNullValue(Type::UIntTy));
           while (CurCTy && !isa<PointerType>(CurCTy)) {
-            const Type *IdxType;
             if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
               // Check for a zero element struct type... if we have one, bail.
               if (CurSTy->getNumElements() == 0) break;
@@ -381,14 +380,12 @@ bool RPR::PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
               // offset zero in the struct.
               //
               ElTy = CurSTy->getElementType(0);
-              IdxType = Type::UByteTy;   // FIXME when PR82 is fixed.
             } else {
               ElTy = cast<ArrayType>(CurCTy)->getElementType();
-              IdxType = Type::LongTy;    // FIXME when PR82 is fixed.
             }
 
             // Insert a zero to index through this type...
-            Indices.push_back(Constant::getNullValue(IdxType));
+            Indices.push_back(Constant::getNullValue(Type::UIntTy));
 
             // Did we find what we're looking for?
             if (ElTy->isLosslesslyConvertibleTo(DestPointedTy)) break;
@@ -565,7 +562,7 @@ bool RPR::DoRaisePass(Function &F) {
   bool Changed = false;
   for (Function::iterator BB = F.begin(), BBE = F.end(); BB != BBE; ++BB)
     for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
-      DEBUG(std::cerr << "Processing: " << *BI);
+      DEBUG(std::cerr << "LevelRaising: " << *BI);
       if (dceInstruction(BI) || doConstantPropagation(BI)) {
         Changed = true; 
         ++NumDCEorCP;