1 ; RUN: opt -S -passes=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 ptr>)
6 define void @test(<2 x ptr> %a) {
7 %A = getelementptr i8, <2 x ptr> %a, <2 x i32> <i32 0, i32 0>
8 call void @helper(<2 x ptr> %A)
12 define <4 x ptr> @test1(<4 x ptr> %a) {
13 %gep = getelementptr i8, <4 x ptr> %a, <4 x i32> zeroinitializer
17 ; CHECK-NEXT: ret <4 x ptr> %a
20 define <4 x ptr> @test2(<4 x ptr> %a) {
21 %gep = getelementptr i8, <4 x ptr> %a
25 ; CHECK-NEXT: ret <4 x ptr> %a
28 %struct = type { double, float }
30 define <4 x ptr> @test3() {
31 %gep = getelementptr %struct, <4 x ptr> 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 ptr> undef
38 %struct.empty = type { }
40 define <4 x ptr> @test4(<4 x ptr> %a) {
41 %gep = getelementptr %struct.empty, <4 x ptr> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
45 ; CHECK-NEXT: ret <4 x ptr> %a
48 define <4 x ptr> @test5() {
49 %c = inttoptr <4 x i64> <i64 1, i64 2, i64 3, i64 4> to <4 x ptr>
50 %gep = getelementptr i8, <4 x ptr> %c, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
54 ; CHECK-NEXT: ret <4 x ptr> getelementptr (i8, <4 x ptr> <ptr inttoptr (i64 1 to ptr), ptr inttoptr (i64 2 to ptr), ptr inttoptr (i64 3 to ptr), ptr inttoptr (i64 4 to ptr)>, <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 ptr> @test6() {
61 ; CHECK-NEXT: ret <16 x ptr> getelementptr inbounds ([24 x [42 x [3 x i32]]], ptr @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]]], ptr @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 ptr> %VectorGep
67 ; CHECK-LABEL: tinkywinky(
68 ; CHECK-NEXT: ret <4 x ptr> undef
69 define <4 x ptr> @tinkywinky() {
70 %patatino = getelementptr i8, ptr undef, <4 x i64> undef
71 ret <4 x ptr> %patatino
76 ; CHECK-NEXT: ret <4 x ptr> undef
77 define <4 x ptr> @dipsy() {
78 %patatino = getelementptr i8, <4 x ptr> undef, <4 x i64> undef
79 ret <4 x ptr> %patatino
83 ; CHECK-LABEL: laalaa(
84 ; CHECK-NEXT: ret <4 x ptr> undef
85 define <4 x ptr> @laalaa() {
86 %patatino = getelementptr i8, <4 x ptr> undef, i64 undef
87 ret <4 x ptr> %patatino
90 define <2 x ptr> @zero_index(ptr %p) {
91 ; CHECK-LABEL: @zero_index(
92 ; CHECK-NEXT: %gep = getelementptr i8, ptr %p, <2 x i64> zeroinitializer
93 ; CHECK-NEXT: ret <2 x ptr> %gep
95 %gep = getelementptr i8, ptr %p, <2 x i64> zeroinitializer
99 define <2 x ptr> @unsized(ptr %p) {
100 ; CHECK-LABEL: @unsized(
101 ; CHECK-NEXT: %gep = getelementptr {}, ptr %p, <2 x i64> undef
102 ; CHECK-NEXT: ret <2 x ptr> %gep
104 %gep = getelementptr {}, ptr %p, <2 x i64> undef