summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/AArch64/reverse-csr-restore-seq.mir
blob: f0f6702992f29f006fe65fad31c0f3fb086140e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# RUN: llc -run-pass=prologepilog -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,BEFORELDSTOPT
# RUN: llc -start-before=prologepilog -stop-after=aarch64-ldst-opt -reverse-csr-restore-seq -o - -mtriple=aarch64-- %s | FileCheck %s --check-prefixes=CHECK,AFTERLDSTOPT
#
--- |

  define void @foo() nounwind { entry: unreachable }

  define void @bar() nounwind { entry: unreachable }

...
---
name:            foo
# CHECK-LABEL: name: foo
tracksRegLiveness: true
body:             |
  bb.0:
    $x19 = IMPLICIT_DEF
    $x20 = IMPLICIT_DEF
    $x21 = IMPLICIT_DEF
    $x22 = IMPLICIT_DEF
    $x23 = IMPLICIT_DEF
    $x24 = IMPLICIT_DEF
    $x25 = IMPLICIT_DEF
    $x26 = IMPLICIT_DEF

  ; The local stack size is 0, so the last ldp in the sequence will also
  ; restore the stack.
  ; CHECK: $x24, $x23 = frame-destroy LDPXi $sp, 2
  ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 4
  ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 6

  ; Before running the load-store optimizer, we emit a ldp and an add.
  ; BEFORELDSTOPT-NEXT: $x26, $x25 = frame-destroy LDPXi $sp, 0
  ; BEFORELDSTOPT-NEXT: $sp = frame-destroy ADDXri $sp, 64, 0

  ; We want to make sure that after running the load-store optimizer, the ldp
  ; and the add get merged into a post-index ldp.
  ; AFTERLDSTOPT-NEXT: early-clobber $sp, $x26, $x25 = frame-destroy LDPXpost $sp, 8

    RET_ReallyLR
...
---
name:            bar
# CHECK-LABEL: name: bar
tracksRegLiveness: true
stack:
  - { id : 0, size: 8, alignment: 4,
  stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
  local-offset: -4, di-variable: '', di-expression: '', di-location: '' }

body:             |
  bb.0:
    $x19 = IMPLICIT_DEF
    $x20 = IMPLICIT_DEF
    $x21 = IMPLICIT_DEF
    $x22 = IMPLICIT_DEF
    $x23 = IMPLICIT_DEF
    $x24 = IMPLICIT_DEF
    $x25 = IMPLICIT_DEF
    $x26 = IMPLICIT_DEF

  ; The local stack size is not 0, and we can combine the CSR stack size with
  ; the local stack size. This results in rewriting the offsets for all the
  ; save/restores and forbids us to merge the stack adjustment and the last pop.
  ; In this case, there is no point of moving the first CSR pair at the end.
  ; CHECK: $x26, $x25 = frame-destroy LDPXi $sp, 2
  ; CHECK-NEXT: $x24, $x23 = frame-destroy LDPXi $sp, 4
  ; CHECK-NEXT: $x22, $x21 = frame-destroy LDPXi $sp, 6
  ; CHECK-NEXT: $x20, $x19 = frame-destroy LDPXi $sp, 8
  ; CHECK-NEXT: $sp = frame-destroy ADDXri $sp, 80, 0
    RET_ReallyLR
...
OpenPOWER on IntegriCloud