[IR] Reintroduce getGEPReturnType(), it will be used in a later patch.
authorDavide Italiano <davide@freebsd.org>
Thu, 27 Oct 2016 23:38:51 +0000 (23:38 +0000)
committerDavide Italiano <davide@freebsd.org>
Thu, 27 Oct 2016 23:38:51 +0000 (23:38 +0000)
llvm-svn: 285365

llvm/include/llvm/IR/Instructions.h
llvm/test/Transforms/InstCombine/gep-vector.ll [new file with mode: 0644]

index b3ad55b..0afbacc 100644 (file)
@@ -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<Value *> IdxList) {
+    return getGEPReturnType(
+      cast<PointerType>(Ptr->getType()->getScalarType())->getElementType(),
+      Ptr, IdxList);
+  }
   static Type *getGEPReturnType(Type *ElTy, Value *Ptr,
                                 ArrayRef<Value *> 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 (file)
index 0000000..ce021bf
--- /dev/null
@@ -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
+}