1; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu < %s | FileCheck %s
2
3target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4target triple = "aarch64--linux-gnu"
5
6define i8 @test1(i8* %p) {
7; CHECK-LABEL: test1
8; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
9  %a = getelementptr inbounds i8, i8* %p, i32 0
10  %v = load i8, i8* %a
11  ret i8 %v
12}
13
14define i16 @test2(i16* %p) {
15; CHECK-LABEL: test2
16; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
17  %a = getelementptr inbounds i16, i16* %p, i32 0
18  %v = load i16, i16* %a
19  ret i16 %v
20}
21
22define i32 @test3(i32* %p) {
23; CHECK-LABEL: test3
24; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
25  %a = getelementptr inbounds i32, i32* %p, i32 0
26  %v = load i32, i32* %a
27  ret i32 %v
28}
29
30define i64 @test4(i64* %p) {
31; CHECK-LABEL: test4
32; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
33  %a = getelementptr inbounds i64, i64* %p, i32 0
34  %v = load i64, i64* %a
35  ret i64 %v
36}
37
38define i8 @test5(i8* %p) {
39; CHECK-LABEL: test5
40; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
41  %a = getelementptr inbounds i8, i8* %p, i32 1024
42  %v = load i8, i8* %a
43  ret i8 %v
44}
45
46define i16 @test6(i16* %p) {
47; CHECK-LABEL: test6
48; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
49  %a = getelementptr inbounds i16, i16* %p, i32 1024
50  %v = load i16, i16* %a
51  ret i16 %v
52}
53
54define i32 @test7(i32* %p) {
55; CHECK-LABEL: test7
56; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
57  %a = getelementptr inbounds i32, i32* %p, i32 1024
58  %v = load i32, i32* %a
59  ret i32 %v
60}
61
62define i64 @test8(i64* %p) {
63; CHECK-LABEL: test8
64; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
65  %a = getelementptr inbounds i64, i64* %p, i32 1024
66  %v = load i64, i64* %a
67  ret i64 %v
68}
69
70define i8 @test9(i8* %p) {
71; CHECK-LABEL: test9
72; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i8, i8*
73  %a = getelementptr inbounds i8, i8* %p, i32 4096
74  %v = load i8, i8* %a
75  ret i8 %v
76}
77
78define i16 @test10(i16* %p) {
79; CHECK-LABEL: test10
80; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
81  %a = getelementptr inbounds i16, i16* %p, i32 4096
82  %v = load i16, i16* %a
83  ret i16 %v
84}
85
86define i32 @test11(i32* %p) {
87; CHECK-LABEL: test11
88; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
89  %a = getelementptr inbounds i32, i32* %p, i32 4096
90  %v = load i32, i32* %a
91  ret i32 %v
92}
93
94define i64 @test12(i64* %p) {
95; CHECK-LABEL: test12
96; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
97  %a = getelementptr inbounds i64, i64* %p, i32 4096
98  %v = load i64, i64* %a
99  ret i64 %v
100}
101
102define i8 @test13(i8* %p) {
103; CHECK-LABEL: test13
104; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
105  %a = getelementptr inbounds i8, i8* %p, i32 -64
106  %v = load i8, i8* %a
107  ret i8 %v
108}
109
110define i16 @test14(i16* %p) {
111; CHECK-LABEL: test14
112; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
113  %a = getelementptr inbounds i16, i16* %p, i32 -64
114  %v = load i16, i16* %a
115  ret i16 %v
116}
117
118define i32 @test15(i32* %p) {
119; CHECK-LABEL: test15
120; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
121  %a = getelementptr inbounds i32, i32* %p, i32 -64
122  %v = load i32, i32* %a
123  ret i32 %v
124}
125
126define i64 @test16(i64* %p) {
127; CHECK-LABEL: test16
128; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
129  %a = getelementptr inbounds i64, i64* %p, i32 -64
130  %v = load i64, i64* %a
131  ret i64 %v
132}
133
134define i8 @test17(i8* %p) {
135; CHECK-LABEL: test17
136; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i8, i8*
137  %a = getelementptr inbounds i8, i8* %p, i32 -1024
138  %v = load i8, i8* %a
139  ret i8 %v
140}
141
142define i16 @test18(i16* %p) {
143; CHECK-LABEL: test18
144; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
145  %a = getelementptr inbounds i16, i16* %p, i32 -1024
146  %v = load i16, i16* %a
147  ret i16 %v
148}
149
150define i32 @test19(i32* %p) {
151; CHECK-LABEL: test19
152; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
153  %a = getelementptr inbounds i32, i32* %p, i32 -1024
154  %v = load i32, i32* %a
155  ret i32 %v
156}
157
158define i64 @test20(i64* %p) {
159; CHECK-LABEL: test20
160; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
161  %a = getelementptr inbounds i64, i64* %p, i32 -1024
162  %v = load i64, i64* %a
163  ret i64 %v
164}
165
166define i8 @test21(i8* %p, i32 %i) {
167; CHECK-LABEL: test21
168; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
169  %a = getelementptr inbounds i8, i8* %p, i32 %i
170  %v = load i8, i8* %a
171  ret i8 %v
172}
173
174define i16 @test22(i16* %p, i32 %i) {
175; CHECK-LABEL: test22
176; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
177  %a = getelementptr inbounds i16, i16* %p, i32 %i
178  %v = load i16, i16* %a
179  ret i16 %v
180}
181
182define i32 @test23(i32* %p, i32 %i) {
183; CHECK-LABEL: test23
184; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i32, i32*
185  %a = getelementptr inbounds i32, i32* %p, i32 %i
186  %v = load i32, i32* %a
187  ret i32 %v
188}
189
190define i64 @test24(i64* %p, i32 %i) {
191; CHECK-LABEL: test24
192; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i64, i64*
193  %a = getelementptr inbounds i64, i64* %p, i32 %i
194  %v = load i64, i64* %a
195  ret i64 %v
196}
197
198define i8 @test25(i8* %p) {
199; CHECK-LABEL: test25
200; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
201  %a = getelementptr inbounds i8, i8* %p, i32 -128
202  %v = load i8, i8* %a
203  ret i8 %v
204}
205
206define i16 @test26(i16* %p) {
207; CHECK-LABEL: test26
208; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i16, i16*
209  %a = getelementptr inbounds i16, i16* %p, i32 -128
210  %v = load i16, i16* %a
211  ret i16 %v
212}
213
214define i32 @test27(i32* %p) {
215; CHECK-LABEL: test27
216; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
217  %a = getelementptr inbounds i32, i32* %p, i32 -128
218  %v = load i32, i32* %a
219  ret i32 %v
220}
221
222define i64 @test28(i64* %p) {
223; CHECK-LABEL: test28
224; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
225  %a = getelementptr inbounds i64, i64* %p, i32 -128
226  %v = load i64, i64* %a
227  ret i64 %v
228}
229
230define i8 @test29(i8* %p) {
231; CHECK-LABEL: test29
232; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
233  %a = getelementptr inbounds i8, i8* %p, i32 -256
234  %v = load i8, i8* %a
235  ret i8 %v
236}
237
238define i16 @test30(i16* %p) {
239; CHECK-LABEL: test30
240; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
241  %a = getelementptr inbounds i16, i16* %p, i32 -256
242  %v = load i16, i16* %a
243  ret i16 %v
244}
245
246define i32 @test31(i32* %p) {
247; CHECK-LABEL: test31
248; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
249  %a = getelementptr inbounds i32, i32* %p, i32 -256
250  %v = load i32, i32* %a
251  ret i32 %v
252}
253
254define i64 @test32(i64* %p) {
255; CHECK-LABEL: test32
256; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
257  %a = getelementptr inbounds i64, i64* %p, i32 -256
258  %v = load i64, i64* %a
259  ret i64 %v
260}
261
262define i8 @test33(i8* %p) {
263; CHECK-LABEL: test33
264; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i8, i8*
265  %a = getelementptr inbounds i8, i8* %p, i32 -512
266  %v = load i8, i8* %a
267  ret i8 %v
268}
269
270define i16 @test34(i16* %p) {
271; CHECK-LABEL: test34
272; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i16, i16*
273  %a = getelementptr inbounds i16, i16* %p, i32 -512
274  %v = load i16, i16* %a
275  ret i16 %v
276}
277
278define i32 @test35(i32* %p) {
279; CHECK-LABEL: test35
280; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i32, i32*
281  %a = getelementptr inbounds i32, i32* %p, i32 -512
282  %v = load i32, i32* %a
283  ret i32 %v
284}
285
286define i64 @test36(i64* %p) {
287; CHECK-LABEL: test36
288; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i64, i64*
289  %a = getelementptr inbounds i64, i64* %p, i32 -512
290  %v = load i64, i64* %a
291  ret i64 %v
292}
293