- Expose passinfo from BreakCriticalEdges pass so that it may be "Required"
[oota-llvm.git] / lib / Transforms / Scalar / InstructionCombining.cpp
index 179f3b296ab080650b3f8584a6335f572ad8b296..b60d1fa9720ff7f4044950bba12d82961f23c099 100644 (file)
@@ -536,6 +536,12 @@ static inline bool isEliminableCastOfCast(const CastInst &CI,
     if (SrcSize >= MidSize && MidSize >= DstSize)
       return true;
 
+    // Cases where the source and destination type are the same, but the middle
+    // type is bigger are noops.
+    //
+    if (SrcSize == DstSize && MidSize > SrcSize)
+      return true;
+
     // If we are monotonically growing, things are more complex.
     //
     if (SrcSize <= MidSize && MidSize <= DstSize) {
@@ -669,7 +675,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
                    *cast<Constant>(GEP.getOperand(1));
       assert(Indices[0] != 0 && "Constant folding of uint's failed!?");
 
-    } else if (*GEP.idx_begin() == ConstantUInt::getNullValue(Type::LongTy)) { 
+    } else if (*GEP.idx_begin() == ConstantUInt::getNullValue(Type::LongTy) &&
+               Src->getNumOperands() != 1) { 
       // Otherwise we can do the fold if the first index of the GEP is a zero
       Indices.insert(Indices.end(), Src->idx_begin(), Src->idx_end());
       Indices.insert(Indices.end(), GEP.idx_begin()+1, GEP.idx_end());