Index: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -1655,14 +1655,14 @@ } } - // Handle gep(bitcast x) and gep(gep x, 0, 0, 0). - Value *StrippedPtr = PtrOp->stripPointerCasts(); - PointerType *StrippedPtrTy = dyn_cast(StrippedPtr->getType()); - // We do not handle pointer-vector geps here. - if (!StrippedPtrTy) + if (GEP.getType()->isVectorTy()) return nullptr; + // Handle gep(bitcast x) and gep(gep x, 0, 0, 0). + Value *StrippedPtr = PtrOp->stripPointerCasts(); + PointerType *StrippedPtrTy = cast(StrippedPtr->getType()); + if (StrippedPtr != PtrOp) { bool HasZeroPointerIndex = false; if (ConstantInt *C = dyn_cast(GEP.getOperand(1))) Index: llvm/trunk/test/Transforms/InstCombine/getelementptr.ll =================================================================== --- llvm/trunk/test/Transforms/InstCombine/getelementptr.ll +++ llvm/trunk/test/Transforms/InstCombine/getelementptr.ll @@ -931,4 +931,15 @@ ret i32 addrspace(1)* %x } +define <2 x i32*> @PR32414(i32** %ptr) { +; CHECK-LABEL: @PR32414( +; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32** %ptr to i32* +; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, i32* [[TMP0]], <2 x i64> +; CHECK-NEXT: ret <2 x i32*> [[TMP1]] +; + %tmp0 = bitcast i32** %ptr to i32* + %tmp1 = getelementptr inbounds i32, i32* %tmp0, <2 x i64> + ret <2 x i32*> %tmp1 +} + ; CHECK: attributes [[NUW]] = { nounwind }