1 ; RUN: opt -cost-model -analyze -mtriple=aarch64--linux-gnu < %s | FileCheck %s
3 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4 target triple = "aarch64--linux-gnu"
6 define i8 @test1(i8* %p) {
8 ; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
9 %a = getelementptr inbounds i8, i8* %p, i32 0
14 define i16 @test2(i16* %p) {
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
22 define i32 @test3(i32* %p) {
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
30 define i64 @test4(i64* %p) {
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
38 define i8 @test5(i8* %p) {
40 ; CHECK: cost of 0 for instruction: {{.*}} getelementptr inbounds i8, i8*
41 %a = getelementptr inbounds i8, i8* %p, i32 1024
46 define i16 @test6(i16* %p) {
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
54 define i32 @test7(i32* %p) {
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
62 define i64 @test8(i64* %p) {
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
70 define i8 @test9(i8* %p) {
72 ; CHECK: cost of 1 for instruction: {{.*}} getelementptr inbounds i8, i8*
73 %a = getelementptr inbounds i8, i8* %p, i32 4096
78 define i16 @test10(i16* %p) {
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
86 define i32 @test11(i32* %p) {
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
94 define i64 @test12(i64* %p) {
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
102 define 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
110 define 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
118 define 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
126 define 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
134 define 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
142 define 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
150 define 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
158 define 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
166 define 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
174 define 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
182 define 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
190 define 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
198 define 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
206 define 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
214 define 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
222 define 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
230 define 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
238 define 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
246 define 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
254 define 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
262 define 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
270 define 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
278 define 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
286 define 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