Index: lib/IR/ConstantFold.cpp =================================================================== --- lib/IR/ConstantFold.cpp +++ lib/IR/ConstantFold.cpp @@ -2062,6 +2062,12 @@ Type *GEPTy = PointerType::get(Ty, PtrTy->getAddressSpace()); if (VectorType *VT = dyn_cast(C->getType())) GEPTy = VectorType::get(GEPTy, VT->getNumElements()); + // When the getelementptr has one or more vector indices, it will + // return a vector of pointers. We guarantee that all the vectors + // in this case will have the same width, so we can just look at + // the first one. + else if (VectorType *VT = dyn_cast(Idxs[0]->getType())) + GEPTy = VectorType::get(GEPTy, VT->getNumElements()); return UndefValue::get(GEPTy); } Index: test/Transforms/InstCombine/gep-vector.ll =================================================================== --- /dev/null +++ test/Transforms/InstCombine/gep-vector.ll @@ -0,0 +1,15 @@ +; RUN: opt -instcombine %s -S | FileCheck %s + +; CHECK-LABEL: patatino +; CHECK-NEXT: ret void +define <8 x i64*> @patatino() { + %el = getelementptr i64, <8 x i64*> undef, <8 x i64> undef + ret <8 x i64*> %el +} + +; CHECK-LABEL: patatino2 +; CHECK-NEXT: ret void +define <8 x i64*> @patatino2() { + %el = getelementptr inbounds i64, i64* undef, <8 x i64> undef + ret <8 x i64*> %el +}