[IR] Reintroduce getGEPReturnType(), it will be used in a later patch.

llvm-svn: 285365
This commit is contained in:
Davide Italiano 2016-10-27 23:38:51 +00:00
parent 6b9c1be4ea
commit e865a525df
2 changed files with 20 additions and 0 deletions

View File

@ -959,6 +959,11 @@ public:
/// Returns the pointer type returned by the GEP /// Returns the pointer type returned by the GEP
/// instruction, which may be a vector of pointers. /// instruction, which may be a vector of pointers.
static Type *getGEPReturnType(Value *Ptr, ArrayRef<Value *> IdxList) {
return getGEPReturnType(
cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(),
Ptr, IdxList);
}
static Type *getGEPReturnType(Type *ElTy, Value *Ptr, static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
ArrayRef<Value *> IdxList) { ArrayRef<Value *> IdxList) {
Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)), Type *PtrTy = PointerType::get(checkGEPType(getIndexedType(ElTy, IdxList)),

View File

@ -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
}