diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index b3ad55bf308c..0afbaccd8b50 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -959,6 +959,11 @@ public: /// Returns the pointer type returned by the GEP /// instruction, which may be a vector of pointers. + static Type *getGEPReturnType(Value *Ptr, ArrayRef IdxList) { + return getGEPReturnType( + cast(Ptr->getType()->getScalarType())->getElementType(), + Ptr, IdxList); + } static Type *getGEPReturnType(Type *ElTy, Value *Ptr, ArrayRef IdxList) { Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)), diff --git a/llvm/test/Transforms/InstCombine/gep-vector.ll b/llvm/test/Transforms/InstCombine/gep-vector.ll new file mode 100644 index 000000000000..ce021bf207fc --- /dev/null +++ b/llvm/test/Transforms/InstCombine/gep-vector.ll @@ -0,0 +1,15 @@ +; RUN: opt -instcombine %s -S | FileCheck %s + +; CHECK-LABEL: patatino +; CHECK-NEXT: ret <8 x i64*> undef +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 <8 x i64*> undef +define <8 x i64*> @patatino2() { + %el = getelementptr inbounds i64, i64* undef, <8 x i64> undef + ret <8 x i64*> %el +}