xref: /llvm-project/llvm/test/CodeGen/RISCV/zcmp-prolog-epilog-crash.mir (revision 97982a8c605fac7c86d02e641a6cd7898b3ca343)
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
2# REQUIRES: asserts
3# RUN: llc  %s -o - -mtriple=riscv32 -mattr=+zcmp -target-abi ilp32 -run-pass=prologepilog \
4# RUN:   -simplify-mir -verify-machineinstrs | FileCheck %s
5
6--- |
7  define hidden void @f(fp128 %a) local_unnamed_addr #0 {
8  entry:
9    %0 = bitcast fp128 %a to i128
10    %and.i = lshr i128 %0, 112
11    %1 = trunc i128 %and.i to i32
12    %2 = and i32 %1, 32767
13    %or.i = or i128 poison, 5192296858534827628530496329220096
14    br label %if.end.i
15
16  if.end.i:                                         ; preds = %entry
17    br i1 poison, label %exit, label %if.then12.i
18
19  if.then12.i:                                      ; preds = %if.end.i
20    %sub13.i = sub nuw nsw i32 16495, %2
21    %sh_prom.i = zext i32 %sub13.i to i128
22    %shr14.i = lshr i128 %or.i, %sh_prom.i
23    %conv15.i = trunc i128 %shr14.i to i32
24    br label %exit
25
26  exit:                                             ; preds = %if.then12.i, %if.end.i
27    %retval.0.i = phi i32 [ %conv15.i, %if.then12.i ], [ -1, %if.end.i ]
28    ret void
29  }
30...
31---
32name:            f
33alignment:       2
34tracksRegLiveness: true
35tracksDebugUserValues: true
36liveins:
37  - { reg: '$x10' }
38frameInfo:
39  maxAlignment:    1
40  localFrameSize:  32
41  savePoint:       '%bb.2'
42  restorePoint:    '%bb.2'
43stack:
44  - { id: 0, size: 32, alignment: 1, local-offset: -32 }
45machineFunctionInfo:
46  varArgsFrameIndex: 0
47  varArgsSaveSize: 0
48body:             |
49  ; CHECK-LABEL: name: f
50  ; CHECK: bb.0.entry:
51  ; CHECK-NEXT:   liveins: $x10
52  ; CHECK-NEXT: {{  $}}
53  ; CHECK-NEXT:   renamable $x10 = ADDI $x0, -1
54  ; CHECK-NEXT: {{  $}}
55  ; CHECK-NEXT: bb.1.if.end.i:
56  ; CHECK-NEXT:   liveins: $x10
57  ; CHECK-NEXT: {{  $}}
58  ; CHECK-NEXT:   BNE $x0, $x0, %bb.3
59  ; CHECK-NEXT:   PseudoBR %bb.2
60  ; CHECK-NEXT: {{  $}}
61  ; CHECK-NEXT: bb.2.if.then12.i:
62  ; CHECK-NEXT:   liveins: $x10
63  ; CHECK-NEXT: {{  $}}
64  ; CHECK-NEXT:   $x2 = frame-setup ADDI $x2, -32
65  ; CHECK-NEXT:   frame-setup CFI_INSTRUCTION def_cfa_offset 32
66  ; CHECK-NEXT:   SB $x0, $x2, 31 :: (store (s8) into %stack.0 + 31)
67  ; CHECK-NEXT:   SB $x0, $x2, 30 :: (store (s8) into %stack.0 + 30)
68  ; CHECK-NEXT:   SB $x0, $x2, 29 :: (store (s8) into %stack.0 + 29)
69  ; CHECK-NEXT:   SB $x0, $x2, 28 :: (store (s8) into %stack.0 + 28)
70  ; CHECK-NEXT:   SB $x0, $x2, 27 :: (store (s8) into %stack.0 + 27)
71  ; CHECK-NEXT:   SB $x0, $x2, 26 :: (store (s8) into %stack.0 + 26)
72  ; CHECK-NEXT:   SB $x0, $x2, 25 :: (store (s8) into %stack.0 + 25)
73  ; CHECK-NEXT:   SB $x0, $x2, 24 :: (store (s8) into %stack.0 + 24)
74  ; CHECK-NEXT:   SB $x0, $x2, 23 :: (store (s8) into %stack.0 + 23)
75  ; CHECK-NEXT:   SB $x0, $x2, 22 :: (store (s8) into %stack.0 + 22)
76  ; CHECK-NEXT:   SB $x0, $x2, 21 :: (store (s8) into %stack.0 + 21)
77  ; CHECK-NEXT:   SB $x0, $x2, 20 :: (store (s8) into %stack.0 + 20)
78  ; CHECK-NEXT:   SB $x0, $x2, 19 :: (store (s8) into %stack.0 + 19)
79  ; CHECK-NEXT:   SB $x0, $x2, 18 :: (store (s8) into %stack.0 + 18)
80  ; CHECK-NEXT:   SB $x0, $x2, 17 :: (store (s8) into %stack.0 + 17)
81  ; CHECK-NEXT:   SB $x0, $x2, 16 :: (store (s8) into %stack.0 + 16)
82  ; CHECK-NEXT:   SB renamable $x10, $x2, 0 :: (store (s8) into %stack.0)
83  ; CHECK-NEXT:   SB renamable $x10, $x2, 4 :: (store (s8) into %stack.0 + 4)
84  ; CHECK-NEXT:   renamable $x11 = SRLI renamable $x10, 24
85  ; CHECK-NEXT:   SB renamable $x11, $x2, 3 :: (store (s8) into %stack.0 + 3)
86  ; CHECK-NEXT:   renamable $x12 = SRLI renamable $x10, 16
87  ; CHECK-NEXT:   SB renamable $x12, $x2, 2 :: (store (s8) into %stack.0 + 2)
88  ; CHECK-NEXT:   renamable $x13 = SRLI renamable $x10, 8
89  ; CHECK-NEXT:   SB renamable $x13, $x2, 1 :: (store (s8) into %stack.0 + 1)
90  ; CHECK-NEXT:   SB renamable $x10, $x2, 8 :: (store (s8) into %stack.0 + 8)
91  ; CHECK-NEXT:   SB renamable $x11, $x2, 7 :: (store (s8) into %stack.0 + 7)
92  ; CHECK-NEXT:   SB renamable $x12, $x2, 6 :: (store (s8) into %stack.0 + 6)
93  ; CHECK-NEXT:   SB renamable $x13, $x2, 5 :: (store (s8) into %stack.0 + 5)
94  ; CHECK-NEXT:   SB killed renamable $x10, $x2, 12 :: (store (s8) into %stack.0 + 12)
95  ; CHECK-NEXT:   SB renamable $x11, $x2, 11 :: (store (s8) into %stack.0 + 11)
96  ; CHECK-NEXT:   SB renamable $x12, $x2, 10 :: (store (s8) into %stack.0 + 10)
97  ; CHECK-NEXT:   SB renamable $x13, $x2, 9 :: (store (s8) into %stack.0 + 9)
98  ; CHECK-NEXT:   SB killed renamable $x11, $x2, 15 :: (store (s8) into %stack.0 + 15)
99  ; CHECK-NEXT:   SB killed renamable $x12, $x2, 14 :: (store (s8) into %stack.0 + 14)
100  ; CHECK-NEXT:   SB killed renamable $x13, $x2, 13 :: (store (s8) into %stack.0 + 13)
101  ; CHECK-NEXT:   $x2 = frame-destroy ADDI $x2, 32
102  ; CHECK-NEXT:   frame-destroy CFI_INSTRUCTION def_cfa_offset 0
103  ; CHECK-NEXT: {{  $}}
104  ; CHECK-NEXT: bb.3.exit:
105  ; CHECK-NEXT:   PseudoRET
106  bb.0.entry:
107    liveins: $x10
108
109    renamable $x10 = ADDI $x0, -1
110
111  bb.1.if.end.i:
112    liveins: $x10
113
114    BNE $x0, $x0, %bb.3
115    PseudoBR %bb.2
116
117  bb.2.if.then12.i:
118    liveins: $x10
119
120    SB $x0, %stack.0, 31 :: (store (s8) into %stack.0 + 31)
121    SB $x0, %stack.0, 30 :: (store (s8) into %stack.0 + 30)
122    SB $x0, %stack.0, 29 :: (store (s8) into %stack.0 + 29)
123    SB $x0, %stack.0, 28 :: (store (s8) into %stack.0 + 28)
124    SB $x0, %stack.0, 27 :: (store (s8) into %stack.0 + 27)
125    SB $x0, %stack.0, 26 :: (store (s8) into %stack.0 + 26)
126    SB $x0, %stack.0, 25 :: (store (s8) into %stack.0 + 25)
127    SB $x0, %stack.0, 24 :: (store (s8) into %stack.0 + 24)
128    SB $x0, %stack.0, 23 :: (store (s8) into %stack.0 + 23)
129    SB $x0, %stack.0, 22 :: (store (s8) into %stack.0 + 22)
130    SB $x0, %stack.0, 21 :: (store (s8) into %stack.0 + 21)
131    SB $x0, %stack.0, 20 :: (store (s8) into %stack.0 + 20)
132    SB $x0, %stack.0, 19 :: (store (s8) into %stack.0 + 19)
133    SB $x0, %stack.0, 18 :: (store (s8) into %stack.0 + 18)
134    SB $x0, %stack.0, 17 :: (store (s8) into %stack.0 + 17)
135    SB $x0, %stack.0, 16 :: (store (s8) into %stack.0 + 16)
136    SB renamable $x10, %stack.0, 0 :: (store (s8) into %stack.0)
137    SB renamable $x10, %stack.0, 4 :: (store (s8) into %stack.0 + 4)
138    renamable $x11 = SRLI renamable $x10, 24
139    SB renamable $x11, %stack.0, 3 :: (store (s8) into %stack.0 + 3)
140    renamable $x12 = SRLI renamable $x10, 16
141    SB renamable $x12, %stack.0, 2 :: (store (s8) into %stack.0 + 2)
142    renamable $x13 = SRLI renamable $x10, 8
143    SB renamable $x13, %stack.0, 1 :: (store (s8) into %stack.0 + 1)
144    SB renamable $x10, %stack.0, 8 :: (store (s8) into %stack.0 + 8)
145    SB renamable $x11, %stack.0, 7 :: (store (s8) into %stack.0 + 7)
146    SB renamable $x12, %stack.0, 6 :: (store (s8) into %stack.0 + 6)
147    SB renamable $x13, %stack.0, 5 :: (store (s8) into %stack.0 + 5)
148    SB killed renamable $x10, %stack.0, 12 :: (store (s8) into %stack.0 + 12)
149    SB renamable $x11, %stack.0, 11 :: (store (s8) into %stack.0 + 11)
150    SB renamable $x12, %stack.0, 10 :: (store (s8) into %stack.0 + 10)
151    SB renamable $x13, %stack.0, 9 :: (store (s8) into %stack.0 + 9)
152    SB killed renamable $x11, %stack.0, 15 :: (store (s8) into %stack.0 + 15)
153    SB killed renamable $x12, %stack.0, 14 :: (store (s8) into %stack.0 + 14)
154    SB killed renamable $x13, %stack.0, 13 :: (store (s8) into %stack.0 + 13)
155
156  bb.3.exit:
157    PseudoRET
158
159...
160