1 # RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -aarch64-load-store-renaming=true -o - %s | FileCheck %s
2 # RUN: llc -run-pass=aarch64-ldst-opt -mtriple=arm64-apple-iphoneos -verify-machineinstrs -aarch64-load-store-renaming=false -o - %s | FileCheck --check-prefix=NO-RENAME %s
10 # CHECK-LABEL: name: test1
12 # CHECK-NEXT: liveins: $x0, $x1
13 # CHECK: $x10, renamable $x8 = LDPXi renamable $x0, 0 :: (load (s64))
14 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
15 # CHECK-NEXT: STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
16 # CHECK-NEXT: renamable $x8 = ADDXrr $x8, $x8
17 # CHECK-NEXT: STPXi renamable $x8, killed $x10, renamable $x0, 10 :: (store (s64), align 4)
18 # CHECK-NEXT: RET undef $lr
22 tracksRegLiveness: true
30 machineFunctionInfo: {}
34 renamable $x9, renamable $x8 = LDPXi renamable $x0, 0 :: (load (s64))
35 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
36 renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
37 STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
38 renamable $x8 = ADDXrr $x8, $x8
39 STRXui renamable $x8, renamable $x0, 10 :: (store (s64), align 4)
44 # CHECK-LABEL: name: test2
46 # CHECK-NEXT: liveins: $x0, $x9, $x1
48 # CHECK: $x10, renamable $x8 = LDPXi renamable $x9, 0 :: (load (s64))
49 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
50 # CHECK-NEXT: STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
51 # CHECK-NEXT: renamable $x8 = ADDXrr $x8, $x8
52 # CHECK-NEXT: STPXi renamable $x8, killed $x10, renamable $x0, 10 :: (store (s64), align 4)
53 # CHECK-NEXT: RET undef $lr
57 tracksRegLiveness: true
65 machineFunctionInfo: {}
68 liveins: $x0, $x9, $x1
69 renamable $x9, renamable $x8 = LDPXi renamable $x9, 0 :: (load (s64))
70 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
71 renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
72 STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
73 renamable $x8 = ADDXrr $x8, $x8
74 STRXui renamable $x8, renamable $x0, 10 :: (store (s64), align 4)
79 # MOVK has a tied operand and we currently do not rename across tied defs.
81 # CHECK-NEXT: liveins: $x0
83 # CHECK: renamable $x8 = MRS 58880
84 # CHECK-NEXT: renamable $x8 = MOVZXi 15309, 0
85 # CHECK-NEXT: renamable $x8 = MOVKXi renamable $x8, 26239, 16
86 # CHECK-NEXT: STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store (s64))
87 # CHECK-NEXT: renamable $x8 = MRS 55840
88 # CHECK-NEXT: STRXui killed renamable $x8, killed renamable $x0, 1, implicit killed $x8 :: (store (s64))
89 # CHECK-NEXT: RET undef $lr
93 tracksRegLiveness: true
98 machineFunctionInfo: {}
103 renamable $x8 = MRS 58880, implicit-def $nzcv
104 renamable $x8 = MOVZXi 15309, 0
105 renamable $x8 = MOVKXi renamable $x8, 26239, 16
106 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store (s64))
107 renamable $x8 = MRS 55840, implicit-def $nzcv
108 STRXui killed renamable $x8, renamable killed $x0, 1, implicit killed $x8 :: (store (s64))
113 # CHECK-LABEL: name: test4
115 # CHECK-NEXT: liveins: $x0, $x1
117 # CHECK: $x9 = MRS 58880
118 # CHECK-NEXT: renamable $x8 = MRS 55840
119 # CHECK-NEXT: STPXi $x9, killed renamable $x8, killed renamable $x0, 0 :: (store (s32))
120 # CHECK-NEXT: RET undef $lr
124 tracksRegLiveness: true
132 machineFunctionInfo: {}
137 renamable $x8 = MRS 58880, implicit-def $nzcv
138 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store (s32))
139 renamable $x8 = MRS 55840, implicit-def $nzcv
140 STRXui killed renamable $x8, renamable killed $x0, 1, implicit killed $x8 :: (store (s32))
145 # CHECK-LABEL: name: test5
147 # CHECK-NEXT: liveins: $x0, $x1
149 # CHECK: $x9 = MRS 58880
150 # CHECK-NEXT: renamable $x8 = MRS 55840
151 # CHECK-NEXT: STPWi $w9, killed renamable $w8, killed renamable $x0, 0 :: (store (s32))
152 # CHECK-NEXT: RET undef $lr
156 tracksRegLiveness: true
164 machineFunctionInfo: {}
169 renamable $x8 = MRS 58880, implicit-def $nzcv
170 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store (s32))
171 renamable $x8 = MRS 55840, implicit-def $nzcv
172 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store (s32))
177 # CHECK-LABEL: name: test6
179 # CHECK: liveins: $x0, $x1, $q3
181 # CHECK: renamable $q9 = LDRQui $x0, 0 :: (load (s128))
182 # CHECK-NEXT: renamable $q9 = XTNv8i16 renamable $q9, killed renamable $q3
183 # CHECK-NEXT: STRQui renamable $q9, renamable $x0, 11 :: (store (s128), align 4)
184 # CHECK-NEXT: renamable $q9 = FADDv2f64 renamable $q9, renamable $q9, implicit $fpcr
185 # CHECK-NEXT: STRQui renamable $q9, renamable $x0, 10 :: (store (s128), align 4)
186 # CHECK-NEXT: RET undef $lr
188 # XTN has a tied use-def.
191 tracksRegLiveness: true
200 machineFunctionInfo: {}
203 liveins: $x0, $x1, $q3
204 renamable $q9 = LDRQui $x0, 0 :: (load (s128))
205 renamable $q9 = XTNv8i16 renamable $q9, killed renamable $q3
206 STRQui renamable $q9, renamable $x0, 11 :: (store (s128), align 4)
207 renamable $q9 = FADDv2f64 renamable $q9, renamable $q9, implicit $fpcr
208 STRQui renamable $q9, renamable $x0, 10 :: (store (s128), align 4)
213 # Currently we do not rename across frame-setup instructions.
214 # CHECK-LABEL: name: test7
216 # CHECK-NEXT: liveins: $x0, $x1
218 # CHECK: $sp = frame-setup SUBXri $sp, 64, 0
219 # CHECK-NEXT: renamable $x9 = frame-setup LDRXui renamable $x0, 0 :: (load (s64))
220 # CHECK-NEXT: STRXui renamable $x9, $x0, 10 :: (store (s64), align 4)
221 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
222 # CHECK-NEXT: STRXui renamable $x9, $x0, 11 :: (store (s64), align 4)
223 # CHECK-NEXT: RET undef $lr
227 tracksRegLiveness: true
239 - { id: 0, type: spill-slot, offset: -48, size: 16, alignment: 16 }
240 - { id: 1, type: spill-slot, offset: -64, size: 16, alignment: 16 }
241 machineFunctionInfo: {}
245 $sp = frame-setup SUBXri $sp, 64, 0
246 renamable $x9 = frame-setup LDRXui renamable $x0, 0 :: (load (s64))
247 STRXui renamable $x9, $x0, 10 :: (store (s64), align 4)
248 renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
249 STRXui renamable $x9, $x0, 11 :: (store (s64), align 4)
253 # CHECK-LABEL: name: test8
255 # CHECK-NEXT: liveins: $x0, $x1
257 # CHECK: renamable $x8 = MRS 58880
258 # CHECK-NEXT: $w9 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x9
259 # CHECK-NEXT: renamable $x8 = MRS 55840
260 # CHECK-NEXT: STPWi $w9, killed renamable $w8, killed renamable $x0, 0 :: (store (s32))
261 # CHECK-NEXT: RET undef $lr
265 tracksRegLiveness: true
273 machineFunctionInfo: {}
278 renamable $x8 = MRS 58880, implicit-def $nzcv
279 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
280 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store (s32))
281 renamable $x8 = MRS 55840, implicit-def $nzcv
282 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store (s32))
287 # The reg class returned for $q9 contains only the first 16 Q registers.
288 # TODO: Can we check that all instructions that require renaming also support
289 # the second 16 Q registers?
290 # CHECK-LABEL: name: test9
292 # CHECK: liveins: $x0, $x1, $q0, $q1, $q2, $q3, $q4, $q5, $q6, $q7
294 # CHECK: renamable $q9 = LDRQui $x0, 0 :: (load (s128))
295 # CHECK-NEXT: STRQui killed renamable $q9, renamable $x0, 10 :: (store (s128), align 4)
296 # CHECK: renamable $q9 = LDRQui $x0, 1 :: (load (s128))
297 # CHECK-NEXT: STRQui renamable $q9, renamable $x0, 11 :: (store (s128), align 4)
298 # CHECK-NEXT: RET undef $lr
302 tracksRegLiveness: true
311 machineFunctionInfo: {}
314 liveins: $x0, $x1, $q0, $q1, $q2, $q3, $q4, $q5, $q6, $q7
315 renamable $q9 = LDRQui $x0, 0 :: (load (s128))
316 STRQui renamable killed $q9, renamable $x0, 10 :: (store (s128), align 4)
317 renamable $q9 = LDRQui $x0, 1 :: (load (s128))
318 STRQui renamable $q9, renamable $x0, 11 :: (store (s128), align 4)
323 # The livein $q7 is killed early, so we can re-use it for renaming.
324 # CHECK-LABEL: name: test10
326 # CHECK: liveins: $x0, $x1, $q0, $q1, $q2, $q3, $q4, $q5, $q6, $q7
328 # CHECK: renamable $q7 = FADDv2f64 renamable $q7, renamable $q7, implicit $fpcr
329 # CHECK-NEXT: STRQui killed renamable $q7, renamable $x0, 100 :: (store (s128), align 4)
330 # CHECK-NEXT: $q7 = LDRQui $x0, 0 :: (load (s128))
331 # CHECK-NEXT: renamable $q9 = LDRQui $x0, 1 :: (load (s128))
332 # CHECK-NEXT: STPQi killed renamable $q9, killed $q7, renamable $x0, 10 :: (store (s128), align 4)
333 # CHECK-NEXT: RET undef $lr
337 tracksRegLiveness: true
346 machineFunctionInfo: {}
349 liveins: $x0, $x1, $q0, $q1, $q2, $q3, $q4, $q5, $q6, $q7
350 renamable $q7 = FADDv2f64 renamable $q7, renamable $q7, implicit $fpcr
351 STRQui renamable killed $q7, renamable $x0, 100 :: (store (s128), align 4)
352 renamable $q9 = LDRQui $x0, 0 :: (load (s128))
353 STRQui renamable killed $q9, renamable $x0, 11 :: (store (s128), align 4)
354 renamable $q9 = LDRQui $x0, 1 :: (load (s128))
355 STRQui renamable killed $q9, renamable $x0, 10 :: (store (s128), align 4)
360 # Make sure we do not use any registers that are defined between paired candidates
361 # ($x14 in this example)
362 # CHECK-LABEL: name: test11
364 # CHECK-NEXT: liveins: $x0, $x1, $x11, $x12, $x13
366 # CHECK: renamable $w10 = LDRWui renamable $x0, 0 :: (load (s64))
367 # CHECK-NEXT: renamable $x9, renamable $x8 = LDPXi renamable $x0, 1 :: (load (s64))
368 # CHECK-NEXT: STRXui killed renamable $x9, renamable $x0, 11 :: (store (s64), align 4)
369 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 3 :: (load (s64))
370 # CHECK-NEXT: renamable $x14 = LDRXui renamable $x0, 5 :: (load (s64))
371 # CHECK-NEXT: STRXui renamable $x9, renamable $x0, 10 :: (store (s64), align 4)
372 # CHECK-NEXT: STRXui killed renamable $x14, renamable $x0, 200 :: (store (s64), align 4)
373 # CHECK-NEXT: renamable $w8 = ADDWrr $w10, $w10
374 # CHECK-NEXT: STRWui renamable $w8, renamable $x0, 100 :: (store (s64), align 4)
375 # CHECK-NEXT: RET undef $lr
379 tracksRegLiveness: true
387 machineFunctionInfo: {}
390 liveins: $x0, $x1, $x11, $x12, $x13
391 renamable $w10 = LDRWui renamable $x0, 0 :: (load (s64))
392 renamable $x9, renamable $x8 = LDPXi renamable $x0, 1 :: (load (s64))
393 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
394 renamable $x9 = LDRXui renamable $x0, 3 :: (load (s64))
395 renamable $x14 = LDRXui renamable $x0, 5 :: (load (s64))
396 STRXui renamable $x9, renamable $x0, 10 :: (store (s64), align 4)
397 STRXui renamable killed $x14, renamable $x0, 200 :: (store (s64), align 4)
398 renamable $w8 = ADDWrr $w10, $w10
399 STRWui renamable $w8, renamable $x0, 100 :: (store (s64), align 4)
404 # Check that we correctly deal with killed registers in stores that get merged forward,
405 # which extends the live range of the first store operand.
406 # CHECK-LABEL: name: test12
408 # CHECK-NEXT: liveins: $x0, $x1
410 # CHECK: renamable $x10 = LDRXui renamable $x0, 0 :: (load (s64))
411 # CHECK-NEXT: $x11, renamable $x8 = LDPXi renamable $x0, 3 :: (load (s64))
412 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
413 # CHECK-NEXT: renamable $x8 = ADDXrr $x8, $x8
414 # CHECK-NEXT: STPXi renamable $x8, killed $x11, renamable $x0, 10 :: (store (s64), align 4)
415 # CHECK-NEXT: STPXi killed renamable $x10, renamable $x9, renamable $x0, 20 :: (store (s64), align 4)
416 # CHECK-NEXT: RET undef $lr
420 tracksRegLiveness: true
428 machineFunctionInfo: {}
432 renamable $x10 = LDRXui renamable $x0, 0 :: (load (s64))
433 STRXui renamable killed $x10, renamable $x0, 20 :: (store (s64), align 4)
434 renamable $x9, renamable $x8 = LDPXi renamable $x0, 3 :: (load (s64))
435 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
436 renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
437 renamable $x8 = ADDXrr $x8, $x8
438 STRXui renamable $x8, renamable $x0, 10 :: (store (s64), align 4)
439 STRXui renamable $x9, renamable $x0, 21 :: (store (s64), align 4)
444 # Make sure we do not use any registers that are defined between def to rename and the first
445 # paired store. ($x14 in this example)
446 # CHECK-LABEL: name: test13
448 # CHECK-NEXT: liveins: $x0, $x1, $x10, $x11, $x12, $x13
449 # CHECK: renamable $x9, renamable $x8 = LDPXi renamable $x0, 0 :: (load (s64))
450 # CHECK-NEXT: renamable $x14 = LDRXui renamable $x0, 4 :: (load (s64))
451 # CHECK-NEXT: STRXui killed renamable $x14, renamable $x0, 100 :: (store (s64), align 4)
452 # CHECK-NEXT: STRXui killed renamable $x9, renamable $x0, 11 :: (store (s64), align 4)
453 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
454 # CHECK-NEXT: STRXui renamable $x9, renamable $x0, 10 :: (store (s64))
455 # CHECK-NEXT: RET undef $lr
459 tracksRegLiveness: true
467 machineFunctionInfo: {}
470 liveins: $x0, $x1, $x10, $x11, $x12, $x13
471 renamable $x9, renamable $x8 = LDPXi renamable $x0, 0 :: (load (s64))
472 renamable $x14 = LDRXui renamable $x0, 4 :: (load (s64))
473 STRXui renamable killed $x14, renamable $x0, 100 :: (store (s64), align 4)
474 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
475 renamable $x9 = LDRXui renamable $x0, 2 :: (load (s64))
476 STRXui renamable $x9, renamable $x0, 10 :: (store (s64))
480 # Make sure we do not rename if pseudo-defs. Noop pseudo instructions like KILL
481 # may lead to a missing definition of the rename register.
483 # CHECK-LABEL: name: test14_pseudo
485 # CHECK-NEXT: liveins: $w8, $fp, $w25
486 # CHECK: renamable $w8 = KILL killed renamable $w8, implicit-def $x8
487 # CHECK-NEXT: STURXi killed renamable $x8, $fp, -40 :: (store (s64))
488 # CHECK-NEXT: $w8 = ORRWrs $wzr, killed $w25, 0, implicit-def $x8
489 # CHECK-NEXT: STURXi killed renamable $x8, $fp, -32 :: (store (s64))
490 # CHECK-NEXT: RET undef $lr
494 tracksRegLiveness: true
502 machineFunctionInfo: {}
505 liveins: $w8, $fp, $w25
507 renamable $w8 = KILL killed renamable $w8, implicit-def $x8
508 STURXi killed renamable $x8, $fp, -40 :: (store (s64))
509 $w8 = ORRWrs $wzr, killed $w25, 0, implicit-def $x8
510 STURXi killed renamable $x8, $fp, -32 :: (store (s64))
514 # Make sure we do not pick a register marked as undef for renaming.
516 # CHECK-LABEL: name: test15_undef_op
518 # CHECK-NEXT: liveins: $x0, $x1, $x8
519 # CHECK: renamable $x10, $x11 = LDPXi renamable $x0, 0 :: (load (s64))
520 # CHECK-NEXT: renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
521 # CHECK-NEXT: STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
522 # CHECK-NEXT: renamable $x10 = ADDXrr $x10, $x10
523 # CHECK-NEXT: STPXi renamable $x10, killed $x11, renamable $x0, 10 :: (store (s64), align 4)
524 # CHECK-NEXT: RET undef $lr
526 name: test15_undef_op
528 tracksRegLiveness: true
536 machineFunctionInfo: {}
539 liveins: $x0, $x1, $x8
540 renamable $x10, renamable $x9 = LDPXi renamable $x0, 0 :: (load (s64))
541 STRXui renamable killed $x9, renamable $x0, 11 :: (store (s64), align 4)
542 renamable $x9 = LDRXui renamable $x0, 1 :: (load (s64))
543 STRXui renamable $x9, renamable $x0, 100 :: (store (s64), align 4)
544 renamable $x10 = ADDXrr $x10, $x10
545 STRXui renamable $x10, renamable $x0, 10 :: (store (s64), align 4)