1 ; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -aarch64-enable-atomic-cfg-tidy=false -disable-cgp-branch-opts -verify-machineinstrs < %s | FileCheck %s
4 ; Test folding of the sign-/zero-extend into the load instruction.
8 define i32 @load_unscaled_zext_i8_to_i32(i64 %a) {
9 ; CHECK-LABEL: load_unscaled_zext_i8_to_i32
10 ; CHECK: ldurb w0, [x0, #-8]
13 %2 = inttoptr i64 %1 to ptr
18 %4 = zext i8 %3 to i32
22 define i32 @load_unscaled_zext_i16_to_i32(i64 %a) {
23 ; CHECK-LABEL: load_unscaled_zext_i16_to_i32
24 ; CHECK: ldurh w0, [x0, #-8]
27 %2 = inttoptr i64 %1 to ptr
32 %4 = zext i16 %3 to i32
36 define i64 @load_unscaled_zext_i8_to_i64(i64 %a) {
37 ; CHECK-LABEL: load_unscaled_zext_i8_to_i64
38 ; CHECK: ldurb w0, [x0, #-8]
41 %2 = inttoptr i64 %1 to ptr
46 %4 = zext i8 %3 to i64
50 define i64 @load_unscaled_zext_i16_to_i64(i64 %a) {
51 ; CHECK-LABEL: load_unscaled_zext_i16_to_i64
52 ; CHECK: ldurh w0, [x0, #-8]
55 %2 = inttoptr i64 %1 to ptr
60 %4 = zext i16 %3 to i64
64 define i64 @load_unscaled_zext_i32_to_i64(i64 %a) {
65 ; CHECK-LABEL: load_unscaled_zext_i32_to_i64
66 ; CHECK: ldur w0, [x0, #-8]
69 %2 = inttoptr i64 %1 to ptr
74 %4 = zext i32 %3 to i64
78 define i32 @load_unscaled_sext_i8_to_i32(i64 %a) {
79 ; CHECK-LABEL: load_unscaled_sext_i8_to_i32
80 ; CHECK: ldursb w0, [x0, #-8]
83 %2 = inttoptr i64 %1 to ptr
88 %4 = sext i8 %3 to i32
92 define i32 @load_unscaled_sext_i16_to_i32(i64 %a) {
93 ; CHECK-LABEL: load_unscaled_sext_i16_to_i32
94 ; CHECK: ldursh w0, [x0, #-8]
97 %2 = inttoptr i64 %1 to ptr
102 %4 = sext i16 %3 to i32
106 define i64 @load_unscaled_sext_i8_to_i64(i64 %a) {
107 ; CHECK-LABEL: load_unscaled_sext_i8_to_i64
108 ; CHECK: ldursb x0, [x0, #-8]
111 %2 = inttoptr i64 %1 to ptr
116 %4 = sext i8 %3 to i64
120 define i64 @load_unscaled_sext_i16_to_i64(i64 %a) {
121 ; CHECK-LABEL: load_unscaled_sext_i16_to_i64
122 ; CHECK: ldursh x0, [x0, #-8]
125 %2 = inttoptr i64 %1 to ptr
126 %3 = load i16, ptr %2
130 %4 = sext i16 %3 to i64
134 define i64 @load_unscaled_sext_i32_to_i64(i64 %a) {
135 ; CHECK-LABEL: load_unscaled_sext_i32_to_i64
136 ; CHECK: ldursw x0, [x0, #-8]
139 %2 = inttoptr i64 %1 to ptr
140 %3 = load i32, ptr %2
144 %4 = sext i32 %3 to i64
149 define i32 @load_register_zext_i8_to_i32(i64 %a, i64 %b) {
150 ; CHECK-LABEL: load_register_zext_i8_to_i32
151 ; CHECK: ldrb w0, [x0, x1]
154 %2 = inttoptr i64 %1 to ptr
159 %4 = zext i8 %3 to i32
163 define i32 @load_register_zext_i16_to_i32(i64 %a, i64 %b) {
164 ; CHECK-LABEL: load_register_zext_i16_to_i32
165 ; CHECK: ldrh w0, [x0, x1]
168 %2 = inttoptr i64 %1 to ptr
169 %3 = load i16, ptr %2
173 %4 = zext i16 %3 to i32
177 define i64 @load_register_zext_i8_to_i64(i64 %a, i64 %b) {
178 ; CHECK-LABEL: load_register_zext_i8_to_i64
179 ; CHECK: ldrb w0, [x0, x1]
182 %2 = inttoptr i64 %1 to ptr
187 %4 = zext i8 %3 to i64
191 define i64 @load_register_zext_i16_to_i64(i64 %a, i64 %b) {
192 ; CHECK-LABEL: load_register_zext_i16_to_i64
193 ; CHECK: ldrh w0, [x0, x1]
196 %2 = inttoptr i64 %1 to ptr
197 %3 = load i16, ptr %2
201 %4 = zext i16 %3 to i64
205 define i64 @load_register_zext_i32_to_i64(i64 %a, i64 %b) {
206 ; CHECK-LABEL: load_register_zext_i32_to_i64
207 ; CHECK: ldr w0, [x0, x1]
210 %2 = inttoptr i64 %1 to ptr
211 %3 = load i32, ptr %2
215 %4 = zext i32 %3 to i64
219 define i32 @load_register_sext_i8_to_i32(i64 %a, i64 %b) {
220 ; CHECK-LABEL: load_register_sext_i8_to_i32
221 ; CHECK: ldrsb w0, [x0, x1]
224 %2 = inttoptr i64 %1 to ptr
229 %4 = sext i8 %3 to i32
233 define i32 @load_register_sext_i16_to_i32(i64 %a, i64 %b) {
234 ; CHECK-LABEL: load_register_sext_i16_to_i32
235 ; CHECK: ldrsh w0, [x0, x1]
238 %2 = inttoptr i64 %1 to ptr
239 %3 = load i16, ptr %2
243 %4 = sext i16 %3 to i32
247 define i64 @load_register_sext_i8_to_i64(i64 %a, i64 %b) {
248 ; CHECK-LABEL: load_register_sext_i8_to_i64
249 ; CHECK: ldrsb x0, [x0, x1]
252 %2 = inttoptr i64 %1 to ptr
257 %4 = sext i8 %3 to i64
261 define i64 @load_register_sext_i16_to_i64(i64 %a, i64 %b) {
262 ; CHECK-LABEL: load_register_sext_i16_to_i64
263 ; CHECK: ldrsh x0, [x0, x1]
266 %2 = inttoptr i64 %1 to ptr
267 %3 = load i16, ptr %2
271 %4 = sext i16 %3 to i64
275 define i64 @load_register_sext_i32_to_i64(i64 %a, i64 %b) {
276 ; CHECK-LABEL: load_register_sext_i32_to_i64
277 ; CHECK: ldrsw x0, [x0, x1]
280 %2 = inttoptr i64 %1 to ptr
281 %3 = load i32, ptr %2
285 %4 = sext i32 %3 to i64
290 define i32 @load_extend_zext_i8_to_i32(i64 %a, i32 %b) {
291 ; CHECK-LABEL: load_extend_zext_i8_to_i32
292 ; CHECK: ldrb w0, [x0, w1, sxtw]
294 %1 = sext i32 %b to i64
296 %3 = inttoptr i64 %2 to ptr
301 %5 = zext i8 %4 to i32
305 define i32 @load_extend_zext_i16_to_i32(i64 %a, i32 %b) {
306 ; CHECK-LABEL: load_extend_zext_i16_to_i32
307 ; CHECK: ldrh w0, [x0, w1, sxtw]
309 %1 = sext i32 %b to i64
311 %3 = inttoptr i64 %2 to ptr
312 %4 = load i16, ptr %3
316 %5 = zext i16 %4 to i32
320 define i64 @load_extend_zext_i8_to_i64(i64 %a, i32 %b) {
321 ; CHECK-LABEL: load_extend_zext_i8_to_i64
322 ; CHECK: ldrb w0, [x0, w1, sxtw]
324 %1 = sext i32 %b to i64
326 %3 = inttoptr i64 %2 to ptr
331 %5 = zext i8 %4 to i64
335 define i64 @load_extend_zext_i16_to_i64(i64 %a, i32 %b) {
336 ; CHECK-LABEL: load_extend_zext_i16_to_i64
337 ; CHECK: ldrh w0, [x0, w1, sxtw]
339 %1 = sext i32 %b to i64
341 %3 = inttoptr i64 %2 to ptr
342 %4 = load i16, ptr %3
346 %5 = zext i16 %4 to i64
350 define i64 @load_extend_zext_i32_to_i64(i64 %a, i32 %b) {
351 ; CHECK-LABEL: load_extend_zext_i32_to_i64
352 ; CHECK: ldr w0, [x0, w1, sxtw]
354 %1 = sext i32 %b to i64
356 %3 = inttoptr i64 %2 to ptr
357 %4 = load i32, ptr %3
361 %5 = zext i32 %4 to i64
365 define i32 @load_extend_sext_i8_to_i32(i64 %a, i32 %b) {
366 ; CHECK-LABEL: load_extend_sext_i8_to_i32
367 ; CHECK: ldrsb w0, [x0, w1, sxtw]
369 %1 = sext i32 %b to i64
371 %3 = inttoptr i64 %2 to ptr
376 %5 = sext i8 %4 to i32
380 define i32 @load_extend_sext_i16_to_i32(i64 %a, i32 %b) {
381 ; CHECK-LABEL: load_extend_sext_i16_to_i32
382 ; CHECK: ldrsh w0, [x0, w1, sxtw]
384 %1 = sext i32 %b to i64
386 %3 = inttoptr i64 %2 to ptr
387 %4 = load i16, ptr %3
391 %5 = sext i16 %4 to i32
395 define i64 @load_extend_sext_i8_to_i64(i64 %a, i32 %b) {
396 ; CHECK-LABEL: load_extend_sext_i8_to_i64
397 ; CHECK: ldrsb x0, [x0, w1, sxtw]
399 %1 = sext i32 %b to i64
401 %3 = inttoptr i64 %2 to ptr
406 %5 = sext i8 %4 to i64
410 define i64 @load_extend_sext_i16_to_i64(i64 %a, i32 %b) {
411 ; CHECK-LABEL: load_extend_sext_i16_to_i64
412 ; CHECK: ldrsh x0, [x0, w1, sxtw]
414 %1 = sext i32 %b to i64
416 %3 = inttoptr i64 %2 to ptr
417 %4 = load i16, ptr %3
421 %5 = sext i16 %4 to i64
425 define i64 @load_extend_sext_i32_to_i64(i64 %a, i32 %b) {
426 ; CHECK-LABEL: load_extend_sext_i32_to_i64
427 ; CHECK: ldrsw x0, [x0, w1, sxtw]
429 %1 = sext i32 %b to i64
431 %3 = inttoptr i64 %2 to ptr
432 %4 = load i32, ptr %3
436 %5 = sext i32 %4 to i64