1 ; RUN: opt -S -instsimplify < %s | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 declare void @helper(<2 x i8*>)
6 define void @test(<2 x i8*> %a) {
7 %A = getelementptr i8, <2 x i8*> %a, <2 x i32> <i32 0, i32 0>
8 call void @helper(<2 x i8*> %A)
12 define <4 x i8*> @test1(<4 x i8*> %a) {
13 %gep = getelementptr i8, <4 x i8*> %a, <4 x i32> zeroinitializer
17 ; CHECK-NEXT: ret <4 x i8*> %a
20 define <4 x i8*> @test2(<4 x i8*> %a) {
21 %gep = getelementptr i8, <4 x i8*> %a
25 ; CHECK-NEXT: ret <4 x i8*> %a
28 %struct = type { double, float }
30 define <4 x float*> @test3() {
31 %gep = getelementptr %struct, <4 x %struct*> undef, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
35 ; CHECK-NEXT: ret <4 x float*> undef
38 %struct.empty = type { }
40 define <4 x %struct.empty*> @test4(<4 x %struct.empty*> %a) {
41 %gep = getelementptr %struct.empty, <4 x %struct.empty*> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
42 ret <4 x %struct.empty*> %gep
45 ; CHECK-NEXT: ret <4 x %struct.empty*> %a
48 define <4 x i8*> @test5() {
49 %c = inttoptr <4 x i64> <i64 1, i64 2, i64 3, i64 4> to <4 x i8*>
50 %gep = getelementptr i8, <4 x i8*> %c, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
54 ; CHECK-NEXT: ret <4 x i8*> getelementptr (i8, <4 x i8*> <i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 2 to i8*), i8* inttoptr (i64 3 to i8*), i8* inttoptr (i64 4 to i8*)>, <4 x i64> <i64 1, i64 1, i64 1, i64 1>)
57 @v = global [24 x [42 x [3 x i32]]] zeroinitializer, align 16
59 define <16 x i32*> @test6() {
61 ; CHECK-NEXT: ret <16 x i32*> getelementptr inbounds ([24 x [42 x [3 x i32]]], [24 x [42 x [3 x i32]]]* @v, <16 x i64> zeroinitializer, <16 x i64> zeroinitializer, <16 x i64> <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, <16 x i64> zeroinitializer)
62 %VectorGep = getelementptr [24 x [42 x [3 x i32]]], [24 x [42 x [3 x i32]]]* @v, i64 0, i64 0, <16 x i64> <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, i64 0
63 ret <16 x i32*> %VectorGep
67 ; CHECK-LABEL: tinkywinky(
68 ; CHECK-NEXT: ret <4 x i8*> undef
69 define <4 x i8*> @tinkywinky() {
70 %patatino = getelementptr i8, i8* undef, <4 x i64> undef
71 ret <4 x i8*> %patatino
76 ; CHECK-NEXT: ret <4 x i8*> undef
77 define <4 x i8*> @dipsy() {
78 %patatino = getelementptr i8, <4 x i8 *> undef, <4 x i64> undef
79 ret <4 x i8*> %patatino
83 ; CHECK-LABEL: laalaa(
84 ; CHECK-NEXT: ret <4 x i8*> undef
85 define <4 x i8*> @laalaa() {
86 %patatino = getelementptr i8, <4 x i8 *> undef, i64 undef
87 ret <4 x i8*> %patatino
90 define <2 x i8*> @zero_index(i8* %p) {
91 ; CHECK-LABEL: @zero_index(
92 ; CHECK-NEXT: %gep = getelementptr i8, i8* %p, <2 x i64> zeroinitializer
93 ; CHECK-NEXT: ret <2 x i8*> %gep
95 %gep = getelementptr i8, i8* %p, <2 x i64> zeroinitializer
99 define <2 x {}*> @unsized({}* %p) {
100 ; CHECK-LABEL: @unsized(
101 ; CHECK-NEXT: %gep = getelementptr {}, {}* %p, <2 x i64> undef
102 ; CHECK-NEXT: ret <2 x {}*> %gep
104 %gep = getelementptr {}, {}* %p, <2 x i64> undef