[PATCH] D32180: [InstSimplify] Deduce correct type for vector gep

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 10:44:04 PDT 2017


davide created this revision.

Fixes 
http://bugs.llvm.org/show_bug.cgi?id=32697

Thanks to Filipe for pointing out the three gep vector variants to cover


https://reviews.llvm.org/D32180

Files:
  lib/Analysis/InstructionSimplify.cpp
  test/Transforms/InstSimplify/gep-vector.ll


Index: test/Transforms/InstSimplify/gep-vector.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstSimplify/gep-vector.ll
@@ -0,0 +1,22 @@
+; RUN: opt -instsimplify -S %s | FileCheck %s
+
+; CHECK-LABEL: tinkywinky(
+; CHECK-NEXT: ret <4 x i8*> undef
+define <4 x i8*> @tinkywinky() {
+  %patatino = getelementptr i8, i8* undef, <4 x i64> undef
+  ret <4 x i8*> %patatino
+}
+
+; CHECK-LABEL: dipsy(
+; CHECK-NEXT: ret <4 x i8*> undef
+define <4 x i8*> @dipsy() {
+  %patatino = getelementptr i8, <4 x i8 *> undef, <4 x i64> undef
+  ret <4 x i8*> %patatino
+}
+
+; CHECK-LABEL: laalaa(
+; CHECK-NEXT: ret <4 x i8*> undef
+define <4 x i8*> @laalaa() {
+  %patatino = getelementptr i8, <4 x i8 *> undef, i64 undef
+  ret <4 x i8*> %patatino
+}
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -3796,6 +3796,8 @@
   Type *GEPTy = PointerType::get(LastType, AS);
   if (VectorType *VT = dyn_cast<VectorType>(Ops[0]->getType()))
     GEPTy = VectorType::get(GEPTy, VT->getNumElements());
+  else if (VectorType *VT = dyn_cast<VectorType>(Ops[1]->getType()))
+    GEPTy = VectorType::get(GEPTy, VT->getNumElements());
 
   if (isa<UndefValue>(Ops[0]))
     return UndefValue::get(GEPTy);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32180.95601.patch
Type: text/x-patch
Size: 1388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170418/0aaa48b4/attachment.bin>


More information about the llvm-commits mailing list