Opaque Pointer Types: GEP API migrations to specify the gep type explicitly
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineCasts.cpp
index 0625d8deca0b5b3d5953978c767745d6cca7fe3e..fe544c2f065db94b7b8384881cac8d3cdbaacfcd 100644 (file)
@@ -1473,9 +1473,11 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
         // If we were able to index down into an element, create the GEP
         // and bitcast the result.  This eliminates one bitcast, potentially
         // two.
-        Value *NGEP = cast<GEPOperator>(GEP)->isInBounds() ?
-          Builder->CreateInBoundsGEP(OrigBase, NewIndices) :
-          Builder->CreateGEP(OrigBase, NewIndices);
+        Value *NGEP = cast<GEPOperator>(GEP)->isInBounds()
+                          ? Builder->CreateInBoundsGEP(OrigBase, NewIndices)
+                          : Builder->CreateGEP(
+                                OrigBase->getType()->getPointerElementType(),
+                                OrigBase, NewIndices);
         NGEP->takeName(GEP);
 
         if (isa<BitCastInst>(CI))