blob: 32234fd5db26413390373858508ee488554d73b5 [file] [log] [blame]
Francis Visoiu Mistrih164560b2018-03-14 20:34:03 +00001# RUN: llc -run-pass=prologepilog -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,BEFORELDSTOPT
2# RUN: llc -start-before=prologepilog -stop-after=aarch64-ldst-opt -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,AFTERLDSTOPT
3#
4--- |
5
6 define void @foo() nounwind { entry: unreachable }
7
8 define void @bar() nounwind { entry: unreachable }
9
10...
11---
12name: foo
13# CHECK-LABEL: name: foo
14tracksRegLiveness: true
15body: |
16 bb.0:
17 $x19 = IMPLICIT_DEF
18 $x20 = IMPLICIT_DEF
19 $x21 = IMPLICIT_DEF
20 $x22 = IMPLICIT_DEF
21 $x23 = IMPLICIT_DEF
22 $x24 = IMPLICIT_DEF
23 $x25 = IMPLICIT_DEF
24 $x26 = IMPLICIT_DEF
25
26 ; The local stack size is 0, so the last ldp in the sequence will also
27 ; restore the stack.
28 ; CHECK: $x24, $x23 = frame-destroy LDPXi $sp, 2
29 ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 4
30 ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 6
31
32 ; Before running the load-store optimizer, we emit a ldp and an add.
33 ; BEFORELDSTOPT-NEXT: $x26, $x25 = frame-destroy LDPXi $sp, 0
34 ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 64, 0
35
36 ; We want to make sure that after running the load-store optimizer, the ldp
37 ; and the add get merged into a post-index ldp.
38 ; AFTERLDSTOPT-NEXT: early-clobber $sp, $x26, $x25 = frame-destroy LDPXpost $sp, 8
39
40 RET_ReallyLR
41...
42---
43name: bar
44# CHECK-LABEL: name: bar
45tracksRegLiveness: true
46stack:
47 - { id : 0, size: 8, alignment: 4,
48 stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
Francis Visoiu Mistrih57fcd342018-04-25 18:58:06 +000049 local-offset: -4, debug-info-variable: '', debug-info-expression: '',
50 debug-info-location: '' }
Francis Visoiu Mistrih164560b2018-03-14 20:34:03 +000051
52body: |
53 bb.0:
54 $x19 = IMPLICIT_DEF
55 $x20 = IMPLICIT_DEF
56 $x21 = IMPLICIT_DEF
57 $x22 = IMPLICIT_DEF
58 $x23 = IMPLICIT_DEF
59 $x24 = IMPLICIT_DEF
60 $x25 = IMPLICIT_DEF
61 $x26 = IMPLICIT_DEF
62
63 ; The local stack size is not 0, and we can combine the CSR stack size with
64 ; the local stack size. This results in rewriting the offsets for all the
65 ; save/restores and forbids us to merge the stack adjustment and the last pop.
66 ; In this case, there is no point of moving the first CSR pair at the end.
67 ; CHECK: $x26, $x25 = frame-destroy LDPXi $sp, 2
68 ; CHECK-NEXT: $x24, $x23 = frame-destroy LDPXi $sp, 4
69 ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 6
70 ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 8
71 ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 80, 0
72 RET_ReallyLR
73...