1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6 declare void @helper(<2 x ptr>)
7 define void @test(<2 x ptr> %a) {
8 ; CHECK-LABEL: define void @test(
9 ; CHECK-SAME: <2 x ptr> [[A:%.*]]) {
10 ; CHECK-NEXT: call void @helper(<2 x ptr> [[A]])
11 ; CHECK-NEXT: ret void
13 %A = getelementptr i8, <2 x ptr> %a, <2 x i32> <i32 0, i32 0>
14 call void @helper(<2 x ptr> %A)
18 define <4 x ptr> @test1(<4 x ptr> %a) {
19 ; CHECK-LABEL: define <4 x ptr> @test1(
20 ; CHECK-SAME: <4 x ptr> [[A:%.*]]) {
21 ; CHECK-NEXT: ret <4 x ptr> [[A]]
23 %gep = getelementptr i8, <4 x ptr> %a, <4 x i32> zeroinitializer
27 define <4 x ptr> @test2(<4 x ptr> %a) {
28 ; CHECK-LABEL: define <4 x ptr> @test2(
29 ; CHECK-SAME: <4 x ptr> [[A:%.*]]) {
30 ; CHECK-NEXT: ret <4 x ptr> [[A]]
32 %gep = getelementptr i8, <4 x ptr> %a
36 %struct = type { double, float }
38 define <4 x ptr> @test3() {
39 ; CHECK-LABEL: define <4 x ptr> @test3() {
40 ; CHECK-NEXT: ret <4 x ptr> undef
42 %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>
46 %struct.empty = type { }
48 define <4 x ptr> @test4(<4 x ptr> %a) {
49 ; CHECK-LABEL: define <4 x ptr> @test4(
50 ; CHECK-SAME: <4 x ptr> [[A:%.*]]) {
51 ; CHECK-NEXT: ret <4 x ptr> [[A]]
53 %gep = getelementptr %struct.empty, <4 x ptr> %a, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
57 define <4 x ptr> @test5() {
58 ; CHECK-LABEL: define <4 x ptr> @test5() {
59 ; 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> splat (i64 1))
61 %c = inttoptr <4 x i64> <i64 1, i64 2, i64 3, i64 4> to <4 x ptr>
62 %gep = getelementptr i8, <4 x ptr> %c, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
66 @v = global [24 x [42 x [3 x i32]]] zeroinitializer, align 16
68 define <16 x ptr> @test6() {
69 ; CHECK-LABEL: define <16 x ptr> @test6() {
70 ; CHECK-NEXT: ret <16 x ptr> getelementptr ([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)
72 %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
73 ret <16 x ptr> %VectorGep
77 define <4 x ptr> @tinkywinky() {
78 ; CHECK-LABEL: define <4 x ptr> @tinkywinky() {
79 ; CHECK-NEXT: ret <4 x ptr> undef
81 %patatino = getelementptr i8, ptr undef, <4 x i64> undef
82 ret <4 x ptr> %patatino
86 define <4 x ptr> @dipsy() {
87 ; CHECK-LABEL: define <4 x ptr> @dipsy() {
88 ; CHECK-NEXT: ret <4 x ptr> undef
90 %patatino = getelementptr i8, <4 x ptr> undef, <4 x i64> undef
91 ret <4 x ptr> %patatino
95 define <4 x ptr> @laalaa() {
96 ; CHECK-LABEL: define <4 x ptr> @laalaa() {
97 ; CHECK-NEXT: ret <4 x ptr> undef
99 %patatino = getelementptr i8, <4 x ptr> undef, i64 undef
100 ret <4 x ptr> %patatino
103 define <2 x ptr> @zero_index(ptr %p) {
104 ; CHECK-LABEL: define <2 x ptr> @zero_index(
105 ; CHECK-SAME: ptr [[P:%.*]]) {
106 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[P]], <2 x i64> zeroinitializer
107 ; CHECK-NEXT: ret <2 x ptr> [[GEP]]
109 %gep = getelementptr i8, ptr %p, <2 x i64> zeroinitializer
113 define <2 x ptr> @unsized(ptr %p) {
114 ; CHECK-LABEL: define <2 x ptr> @unsized(
115 ; CHECK-SAME: ptr [[P:%.*]]) {
116 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr {}, ptr [[P]], <2 x i64> undef
117 ; CHECK-NEXT: ret <2 x ptr> [[GEP]]
119 %gep = getelementptr {}, ptr %p, <2 x i64> undef