summaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen/SystemZ/frame-28.mir
blob: dd5933a9c7b4b4c73860a5888b18a12c21ff554f (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# RUN: llc -mtriple=s390x-linux-gnu -start-before=prologepilog %s -o - -mcpu=z14 \
# RUN:   -verify-machineinstrs 2>&1 | FileCheck %s
# REQUIRES: asserts
#
# Test that redundant frame addressing anchor points are removed by
# MachineLateInstrsCleanup.

--- |
  define void @fun1() { ret void }
  define void @fun2() { ret void }
  define void @fun3() { ret void }
  define void @fun4() { ret void }
  define void @fun5() { ret void }
  define void @fun6() { ret void }
  define void @fun7() { ret void }
  define void @fun8() { ret void }

  declare i32 @foo()

  @ptr = external dso_local local_unnamed_addr global ptr
---

# Test elimination of redundant LAYs in successor blocks.
# CHECK-LABEL: fun1:
# CHECK: lay %r1, 4096(%r15)
# CHECK: # %bb.1:
# CHECK-NOT: lay
# CHECK: .LBB0_2:
# CHECK-NOT: lay
---
name:            fun1
tracksRegLiveness: true
stack:
  - { id: 0, size: 5000 }
  - { id: 1, size: 2500 }
  - { id: 2, size: 2500 }

machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    liveins: $f16d
    successors: %bb.2(0x00000001), %bb.1(0x7fffffff)

    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.1, 0, $noreg
    CHIMux undef $r0l, 3, implicit-def $cc
    BRC 14, 8, %bb.2, implicit killed $cc
    J %bb.1

  bb.1:
    liveins: $f16d
    VST64 renamable $f16d, %stack.2, 0, $noreg
    J %bb.2

  bb.2:
    liveins: $f16d
    VST64 renamable $f16d, %stack.1, 0, $noreg
    Return
...

# In this function the LAY in bb.1 will have a different offset, so the first
# LAY in bb.2 must remain.
# CHECK-LABEL: fun2:
# CHECK: lay %r1, 4096(%r15)
# CHECK: # %bb.1:
# CHECK: lay %r1, 8192(%r15)
# CHECK: .LBB1_2:
# CHECK: lay %r1, 4096(%r15)
# CHECK-NOT: lay
---
name:            fun2
tracksRegLiveness: true
stack:
  - { id: 0, size: 5000 }
  - { id: 1, size: 5000 }
  - { id: 2, size: 2500 }

machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    liveins: $f16d
    successors: %bb.2(0x00000001), %bb.1(0x7fffffff)

    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.1, 0, $noreg
    CHIMux undef $r0l, 3, implicit-def $cc
    BRC 14, 8, %bb.2, implicit killed $cc
    J %bb.1

  bb.1:
    liveins: $f16d
    VST64 renamable $f16d, %stack.2, 0, $noreg
    J %bb.2

  bb.2:
    liveins: $f16d
    VST64 renamable $f16d, %stack.1, 0, $noreg
    VST64 renamable $f16d, %stack.1, 0, $noreg
    Return
...

# Test case with a loop (with room for improvement: since %r1 is not clobbered
# inside the loop only the first LAY is needed).
# CHECK-LABEL: fun3:
# CHECK: lay %r1, 4096(%r15)
# CHECK: .LBB2_1:
# CHECK: lay %r1, 4096(%r15)
# CHECK: .LBB2_2:
# CHECK-NOT: lay %r1, 4096(%r15)
---
name:            fun3
tracksRegLiveness: true
stack:
  - { id: 0, size: 5000 }
  - { id: 1, size: 2500 }
  - { id: 2, size: 2500 }

machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    liveins: $f16d
    successors: %bb.2(0x00000001), %bb.1(0x7fffffff)

    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.1, 0, $noreg
    CHIMux undef $r0l, 3, implicit-def $cc
    BRC 14, 8, %bb.2, implicit killed $cc
    J %bb.1

  bb.1:
    liveins: $f16d
    successors: %bb.2(0x00000001), %bb.1(0x7fffffff)

    VST64 renamable $f16d, %stack.2, 0, $noreg
    CHIMux undef $r0l, 3, implicit-def $cc
    BRC 14, 8, %bb.1, implicit killed $cc
    J %bb.2

  bb.2:
    liveins: $f16d
    VST64 renamable $f16d, %stack.1, 0, $noreg
    Return
...

# Test case with a call which clobbers r1: the second LAY after the call is needed.
# CHECK-LABEL: fun4:
# CHECK: lay %r1, 4096(%r15)
# CHECK: brasl
# CHECK: lay %r1, 4096(%r15)
---
name:            fun4
tracksRegLiveness: true
stack:
  - { id: 0, size: 5000 }
  - { id: 1, size: 2500 }

machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    liveins: $f16d

    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.1, 0, $noreg
    ADJCALLSTACKDOWN 0, 0
    CallBRASL @foo, csr_systemz_elf, implicit-def dead $r14d, implicit-def dead $cc, implicit $fpc, implicit-def $r2l
    ADJCALLSTACKUP 0, 0
    $f17d = IMPLICIT_DEF
    VST64 renamable $f17d, %stack.1, 0, $noreg
    Return
...

# Test case where index reg is loaded instead of using an LAY. Only one LGHI is needed.
# CHECK-LABEL: fun5:
# CHECK: lghi %r1, 4096
# CHECK-NOT: lghi
---
name:            fun5
tracksRegLiveness: true
stack:
  - { id: 0, size: 5000 }
  - { id: 1, size: 2500 }

machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    liveins: $f16d

    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    VST64 renamable $f16d, %stack.0, 0, $noreg
    $f0q = nofpexcept LXEB %stack.1, 0, $noreg, implicit $fpc
    $f1q = nofpexcept LXEB %stack.1, 0, $noreg, implicit $fpc
    Return
...

# Test where the constant is a Global. Only one LARL is needed.
# CHECK-LABEL: fun6:
# CHECK: larl %r1, ptr
# CHECK-NOT: larl
---
name:            fun6
alignment:       16
tracksRegLiveness: true
tracksDebugUserValues: true
frameInfo:
  maxAlignment:    1
  maxCallFrameSize: 0
fixedStack:
  - { id: 0, offset: -160, size: 8, alignment: 8 }
machineFunctionInfo: {}
body:             |
  bb.0:
    successors: %bb.2(0x30000000), %bb.1(0x50000000)

    renamable $r1d = LARL @ptr
    CGHSI killed renamable $r1d, 0, 0, implicit-def $cc :: (volatile dereferenceable load (s64) from @ptr)
    BRC 14, 8, %bb.2, implicit killed $cc
    J %bb.1

  bb.1:
    renamable $r1d = LARL @ptr
    MVGHI killed renamable $r1d, 0, 0

  bb.2:
    Return

...

# Load of an invariant location (GOT). Only one LGRL is needed.
# CHECK-LABEL: fun7:
# CHECK: lgrl %r1, ptr
# CHECK-NOT: lgrl
---
name:            fun7
alignment:       16
tracksRegLiveness: true
tracksDebugUserValues: true
frameInfo:
  maxAlignment:    1
  maxCallFrameSize: 0
fixedStack:
  - { id: 0, offset: -160, size: 8, alignment: 8 }
machineFunctionInfo: {}
body:             |
  bb.0:
    successors: %bb.2(0x30000000), %bb.1(0x50000000)
  
    renamable $r1d = LGRL @ptr :: (load (s64) from got)
    CGHSI killed renamable $r1d, 0, 0, implicit-def $cc :: (volatile dereferenceable load (s64) from @ptr)
    BRC 14, 8, %bb.2, implicit killed $cc
    J %bb.1
  
  bb.1:
    renamable $r1d = LGRL @ptr :: (load (s64) from got)
    MVGHI killed renamable $r1d, 0, 0
  
  bb.2:
    Return

...

# Load from constant pool. Only one LARL is needed.
# CHECK-LABEL: fun8:
# CHECK: larl %r1, .LCPI7_0
# CHECK-NOT: larl
---
name:            fun8
alignment:       16
tracksRegLiveness: true
tracksDebugUserValues: true
liveins:
  - { reg: '$f0s' }
frameInfo:
  maxAlignment:    1
  maxCallFrameSize: 0
fixedStack:
  - { id: 0, offset: -160, size: 8, alignment: 8 }
constants:
  - id:              0
    value:           float 0x43E0000000000000
    alignment:       4
machineFunctionInfo: {}
body:             |
  bb.0 (%ir-block.0):
    successors: %bb.1, %bb.2
    liveins: $f0s

    renamable $r1d = LARL %const.0
    renamable $f1s = LE killed renamable $r1d, 0, $noreg :: (load (s32) from constant-pool)
    nofpexcept CEBR renamable $f0s, renamable $f1s, implicit-def $cc, implicit $fpc
    BRC 15, 11, %bb.2, implicit killed $cc

  bb.1:
    liveins: $f0s

    J %bb.3

  bb.2 (%ir-block.0):
    liveins: $f0s, $f1s

    renamable $r1d = LARL %const.0
    renamable $f1s = LE killed renamable $r1d, 0, $noreg :: (load (s32) from constant-pool)

  bb.3 (%ir-block.0):
    liveins: $r2d

    Return

...