1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=aarch64--linux-gnu < %s | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64--linux-gnu"
7 define i8 @test1(ptr %p) {
9 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 1
10 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
11 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
13 %a = getelementptr inbounds i8, ptr %p, i32 1
18 define i16 @test2(ptr %p) {
19 ; CHECK-LABEL: 'test2'
20 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 1
21 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
22 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
24 %a = getelementptr inbounds i16, ptr %p, i32 1
29 define i32 @test3(ptr %p) {
30 ; CHECK-LABEL: 'test3'
31 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 1
32 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
33 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
35 %a = getelementptr inbounds i32, ptr %p, i32 1
40 define i64 @test4(ptr %p) {
41 ; CHECK-LABEL: 'test4'
42 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 1
43 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
44 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
46 %a = getelementptr inbounds i64, ptr %p, i32 1
51 define i8 @test5(ptr %p) {
52 ; CHECK-LABEL: 'test5'
53 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 1024
54 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
55 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
57 %a = getelementptr inbounds i8, ptr %p, i32 1024
62 define i16 @test6(ptr %p) {
63 ; CHECK-LABEL: 'test6'
64 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 1024
65 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
66 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
68 %a = getelementptr inbounds i16, ptr %p, i32 1024
73 define i32 @test7(ptr %p) {
74 ; CHECK-LABEL: 'test7'
75 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 1024
76 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
77 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
79 %a = getelementptr inbounds i32, ptr %p, i32 1024
84 define i64 @test8(ptr %p) {
85 ; CHECK-LABEL: 'test8'
86 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 1024
87 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
88 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
90 %a = getelementptr inbounds i64, ptr %p, i32 1024
95 define i8 @test9(ptr %p) {
96 ; CHECK-LABEL: 'test9'
97 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 4096
98 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
99 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
101 %a = getelementptr inbounds i8, ptr %p, i32 4096
106 define i16 @test10(ptr %p) {
107 ; CHECK-LABEL: 'test10'
108 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 4096
109 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
110 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
112 %a = getelementptr inbounds i16, ptr %p, i32 4096
113 %v = load i16, ptr %a
117 define i32 @test11(ptr %p) {
118 ; CHECK-LABEL: 'test11'
119 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 4096
120 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
121 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
123 %a = getelementptr inbounds i32, ptr %p, i32 4096
124 %v = load i32, ptr %a
128 define i64 @test12(ptr %p) {
129 ; CHECK-LABEL: 'test12'
130 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 4096
131 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
132 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
134 %a = getelementptr inbounds i64, ptr %p, i32 4096
135 %v = load i64, ptr %a
139 define i8 @test13(ptr %p) {
140 ; CHECK-LABEL: 'test13'
141 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -64
142 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
143 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
145 %a = getelementptr inbounds i8, ptr %p, i32 -64
150 define i16 @test14(ptr %p) {
151 ; CHECK-LABEL: 'test14'
152 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -64
153 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
154 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
156 %a = getelementptr inbounds i16, ptr %p, i32 -64
157 %v = load i16, ptr %a
161 define i32 @test15(ptr %p) {
162 ; CHECK-LABEL: 'test15'
163 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -64
164 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
165 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
167 %a = getelementptr inbounds i32, ptr %p, i32 -64
168 %v = load i32, ptr %a
172 define i64 @test16(ptr %p) {
173 ; CHECK-LABEL: 'test16'
174 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -64
175 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
176 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
178 %a = getelementptr inbounds i64, ptr %p, i32 -64
179 %v = load i64, ptr %a
183 define i8 @test17(ptr %p) {
184 ; CHECK-LABEL: 'test17'
185 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -1024
186 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
187 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
189 %a = getelementptr inbounds i8, ptr %p, i32 -1024
194 define i16 @test18(ptr %p) {
195 ; CHECK-LABEL: 'test18'
196 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -1024
197 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
198 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
200 %a = getelementptr inbounds i16, ptr %p, i32 -1024
201 %v = load i16, ptr %a
205 define i32 @test19(ptr %p) {
206 ; CHECK-LABEL: 'test19'
207 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -1024
208 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
209 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
211 %a = getelementptr inbounds i32, ptr %p, i32 -1024
212 %v = load i32, ptr %a
216 define i64 @test20(ptr %p) {
217 ; CHECK-LABEL: 'test20'
218 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -1024
219 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
220 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
222 %a = getelementptr inbounds i64, ptr %p, i32 -1024
223 %v = load i64, ptr %a
227 define i8 @test21(ptr %p, i32 %i) {
228 ; CHECK-LABEL: 'test21'
229 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 %i
230 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
231 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
233 %a = getelementptr inbounds i8, ptr %p, i32 %i
238 define i16 @test22(ptr %p, i32 %i) {
239 ; CHECK-LABEL: 'test22'
240 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 %i
241 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
242 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
244 %a = getelementptr inbounds i16, ptr %p, i32 %i
245 %v = load i16, ptr %a
249 define i32 @test23(ptr %p, i32 %i) {
250 ; CHECK-LABEL: 'test23'
251 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 %i
252 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
253 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
255 %a = getelementptr inbounds i32, ptr %p, i32 %i
256 %v = load i32, ptr %a
260 define i64 @test24(ptr %p, i32 %i) {
261 ; CHECK-LABEL: 'test24'
262 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 %i
263 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
264 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
266 %a = getelementptr inbounds i64, ptr %p, i32 %i
267 %v = load i64, ptr %a
271 define i8 @test25(ptr %p) {
272 ; CHECK-LABEL: 'test25'
273 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -128
274 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
275 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
277 %a = getelementptr inbounds i8, ptr %p, i32 -128
282 define i16 @test26(ptr %p) {
283 ; CHECK-LABEL: 'test26'
284 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -128
285 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
286 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
288 %a = getelementptr inbounds i16, ptr %p, i32 -128
289 %v = load i16, ptr %a
293 define i32 @test27(ptr %p) {
294 ; CHECK-LABEL: 'test27'
295 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -128
296 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
297 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
299 %a = getelementptr inbounds i32, ptr %p, i32 -128
300 %v = load i32, ptr %a
304 define i64 @test28(ptr %p) {
305 ; CHECK-LABEL: 'test28'
306 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -128
307 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
308 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
310 %a = getelementptr inbounds i64, ptr %p, i32 -128
311 %v = load i64, ptr %a
315 define i8 @test29(ptr %p) {
316 ; CHECK-LABEL: 'test29'
317 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -256
318 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
319 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
321 %a = getelementptr inbounds i8, ptr %p, i32 -256
326 define i16 @test30(ptr %p) {
327 ; CHECK-LABEL: 'test30'
328 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -256
329 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
330 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
332 %a = getelementptr inbounds i16, ptr %p, i32 -256
333 %v = load i16, ptr %a
337 define i32 @test31(ptr %p) {
338 ; CHECK-LABEL: 'test31'
339 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -256
340 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
341 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
343 %a = getelementptr inbounds i32, ptr %p, i32 -256
344 %v = load i32, ptr %a
348 define i64 @test32(ptr %p) {
349 ; CHECK-LABEL: 'test32'
350 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -256
351 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
352 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
354 %a = getelementptr inbounds i64, ptr %p, i32 -256
355 %v = load i64, ptr %a
359 define i8 @test33(ptr %p) {
360 ; CHECK-LABEL: 'test33'
361 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i8, ptr %p, i32 -512
362 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i8, ptr %a, align 1
363 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i8 %v
365 %a = getelementptr inbounds i8, ptr %p, i32 -512
370 define i16 @test34(ptr %p) {
371 ; CHECK-LABEL: 'test34'
372 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i16, ptr %p, i32 -512
373 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i16, ptr %a, align 2
374 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i16 %v
376 %a = getelementptr inbounds i16, ptr %p, i32 -512
377 %v = load i16, ptr %a
381 define i32 @test35(ptr %p) {
382 ; CHECK-LABEL: 'test35'
383 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i32, ptr %p, i32 -512
384 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i32, ptr %a, align 4
385 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i32 %v
387 %a = getelementptr inbounds i32, ptr %p, i32 -512
388 %v = load i32, ptr %a
392 define i64 @test36(ptr %p) {
393 ; CHECK-LABEL: 'test36'
394 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %a = getelementptr inbounds i64, ptr %p, i32 -512
395 ; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %v = load i64, ptr %a, align 8
396 ; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret i64 %v
398 %a = getelementptr inbounds i64, ptr %p, i32 -512
399 %v = load i64, ptr %a