Index: lib/IR/ConstantFold.cpp =================================================================== --- lib/IR/ConstantFold.cpp +++ lib/IR/ConstantFold.cpp @@ -2065,6 +2065,18 @@ Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); if (VectorType *VT = dyn_cast(C->getType())) GEPTy = VectorType::get(GEPTy, VT->getNumElements()); + + // The GEP returns a vector of pointers when one of more of + // its arguments is a vector. + for (unsigned i = 0, e = Idxs.size(); i != e; ++i) { + if (auto *VT = dyn_cast(Idxs[i]->getType())) { + GEPTy = + VectorType::get(PointerType::get(Ty, PtrTy->getAddressSpace()), + VT->getNumElements()); + break; + } + } + return Constant::getNullValue(GEPTy); } } Index: test/Transforms/InstCombine/pr34627.ll =================================================================== --- /dev/null +++ test/Transforms/InstCombine/pr34627.ll @@ -0,0 +1,11 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -S -instcombine %s |FileCheck %s + +define <2 x i16> @patatino() { +; CHECK-LABEL: @patatino( +; CHECK-NEXT: ret <2 x i16> zeroinitializer +; + %tmp2 = getelementptr inbounds [1 x i16], [1 x i16]* null, i16 0, <2 x i16> undef + %tmp3 = ptrtoint <2 x i16*> %tmp2 to <2 x i16> + ret <2 x i16> %tmp3 +}