arm-bf16-pcs.ll
9.89 KB
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
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple armv8.6a-arm-none-eabi -o - %s | FileCheck %s --check-prefix=BASE --check-prefix=BASE-ARM
; RUN: llc -mtriple thumbv8.6a-arm-none-eabi -o - %s | FileCheck %s --check-prefix=BASE --check-prefix=BASE-THUMB
; RUN: llc -mtriple armv8.6a-arm-none-eabi -mattr=+fullfp16 -o - %s | FileCheck %s --check-prefix=FULLFP16 --check-prefix=FULLFP16-ARM
; RUN: llc -mtriple thumbv8.6a-arm-none-eabi -mattr=+fullfp16 -o - %s | FileCheck %s --check-prefix=FULLFP16 --check-prefix=FULLFP16-THUMB
define bfloat @bf_load_soft(bfloat* %p) {
; BASE-LABEL: bf_load_soft:
; BASE: @ %bb.0:
; BASE-NEXT: ldrh r0, [r0]
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_load_soft:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vldr.16 s0, [r0]
; FULLFP16-NEXT: vmov r0, s0
; FULLFP16-NEXT: bx lr
%f = load bfloat, bfloat* %p, align 2
ret bfloat %f
}
define arm_aapcs_vfpcc bfloat @bf_load_hard(bfloat* %p) {
; BASE-LABEL: bf_load_hard:
; BASE: @ %bb.0:
; BASE-NEXT: ldrh r0, [r0]
; BASE-NEXT: vmov s0, r0
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_load_hard:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vldr.16 s0, [r0]
; FULLFP16-NEXT: bx lr
%f = load bfloat, bfloat* %p, align 2
ret bfloat %f
}
define void @bf_store_soft(bfloat* %p, bfloat %f) {
; BASE-LABEL: bf_store_soft:
; BASE: @ %bb.0:
; BASE-NEXT: strh r1, [r0]
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_store_soft:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vmov.f16 s0, r1
; FULLFP16-NEXT: vstr.16 s0, [r0]
; FULLFP16-NEXT: bx lr
store bfloat %f, bfloat* %p, align 2
ret void
}
define arm_aapcs_vfpcc void @bf_store_hard(bfloat* %p, bfloat %f) {
; BASE-LABEL: bf_store_hard:
; BASE: @ %bb.0:
; BASE-NEXT: vmov r1, s0
; BASE-NEXT: strh r1, [r0]
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_store_hard:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vstr.16 s0, [r0]
; FULLFP16-NEXT: bx lr
store bfloat %f, bfloat* %p, align 2
ret void
}
define i32 @bf_to_int_soft(bfloat %f) {
; BASE-LABEL: bf_to_int_soft:
; BASE: @ %bb.0:
; BASE-NEXT: uxth r0, r0
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_to_int_soft:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vmov.f16 s0, r0
; FULLFP16-NEXT: vmov.f16 r0, s0
; FULLFP16-NEXT: bx lr
%h = bitcast bfloat %f to i16
%w = zext i16 %h to i32
ret i32 %w
}
define arm_aapcs_vfpcc i32 @bf_to_int_hard(bfloat %f) {
; BASE-LABEL: bf_to_int_hard:
; BASE: @ %bb.0:
; BASE-NEXT: vmov r0, s0
; BASE-NEXT: uxth r0, r0
; BASE-NEXT: bx lr
;
; FULLFP16-LABEL: bf_to_int_hard:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vmov.f16 r0, s0
; FULLFP16-NEXT: bx lr
%h = bitcast bfloat %f to i16
%w = zext i16 %h to i32
ret i32 %w
}
define bfloat @bf_from_int_soft(i32 %w) {
; BASE-ARM-LABEL: bf_from_int_soft:
; BASE-ARM: @ %bb.0:
; BASE-ARM-NEXT: .pad #4
; BASE-ARM-NEXT: sub sp, sp, #4
; BASE-ARM-NEXT: strh r0, [sp, #2]
; BASE-ARM-NEXT: ldrh r0, [sp, #2]
; BASE-ARM-NEXT: add sp, sp, #4
; BASE-ARM-NEXT: bx lr
;
; BASE-THUMB-LABEL: bf_from_int_soft:
; BASE-THUMB: @ %bb.0:
; BASE-THUMB-NEXT: .pad #4
; BASE-THUMB-NEXT: sub sp, #4
; BASE-THUMB-NEXT: strh.w r0, [sp, #2]
; BASE-THUMB-NEXT: ldrh.w r0, [sp, #2]
; BASE-THUMB-NEXT: add sp, #4
; BASE-THUMB-NEXT: bx lr
;
; FULLFP16-LABEL: bf_from_int_soft:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vmov.f16 s0, r0
; FULLFP16-NEXT: vmov r0, s0
; FULLFP16-NEXT: bx lr
%h = trunc i32 %w to i16
%f = bitcast i16 %h to bfloat
ret bfloat %f
}
define arm_aapcs_vfpcc bfloat @bf_from_int_hard(i32 %w) {
; BASE-ARM-LABEL: bf_from_int_hard:
; BASE-ARM: @ %bb.0:
; BASE-ARM-NEXT: .pad #4
; BASE-ARM-NEXT: sub sp, sp, #4
; BASE-ARM-NEXT: strh r0, [sp, #2]
; BASE-ARM-NEXT: ldrh r0, [sp, #2]
; BASE-ARM-NEXT: vmov s0, r0
; BASE-ARM-NEXT: add sp, sp, #4
; BASE-ARM-NEXT: bx lr
;
; BASE-THUMB-LABEL: bf_from_int_hard:
; BASE-THUMB: @ %bb.0:
; BASE-THUMB-NEXT: .pad #4
; BASE-THUMB-NEXT: sub sp, #4
; BASE-THUMB-NEXT: strh.w r0, [sp, #2]
; BASE-THUMB-NEXT: ldrh.w r0, [sp, #2]
; BASE-THUMB-NEXT: vmov s0, r0
; BASE-THUMB-NEXT: add sp, #4
; BASE-THUMB-NEXT: bx lr
;
; FULLFP16-LABEL: bf_from_int_hard:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: vmov.f16 s0, r0
; FULLFP16-NEXT: bx lr
%h = trunc i32 %w to i16
%f = bitcast i16 %h to bfloat
ret bfloat %f
}
define bfloat @test_fncall_soft(bfloat %bf, bfloat (bfloat, bfloat)* %f) {
; BASE-ARM-LABEL: test_fncall_soft:
; BASE-ARM: @ %bb.0:
; BASE-ARM-NEXT: .save {r4, r5, r11, lr}
; BASE-ARM-NEXT: push {r4, r5, r11, lr}
; BASE-ARM-NEXT: .pad #8
; BASE-ARM-NEXT: sub sp, sp, #8
; BASE-ARM-NEXT: uxth r5, r0
; BASE-ARM-NEXT: mov r4, r1
; BASE-ARM-NEXT: mov r0, r5
; BASE-ARM-NEXT: mov r1, r5
; BASE-ARM-NEXT: blx r4
; BASE-ARM-NEXT: strh r0, [sp, #6]
; BASE-ARM-NEXT: uxth r1, r0
; BASE-ARM-NEXT: mov r0, r5
; BASE-ARM-NEXT: blx r4
; BASE-ARM-NEXT: ldrh r0, [sp, #6]
; BASE-ARM-NEXT: add sp, sp, #8
; BASE-ARM-NEXT: pop {r4, r5, r11, pc}
;
; BASE-THUMB-LABEL: test_fncall_soft:
; BASE-THUMB: @ %bb.0:
; BASE-THUMB-NEXT: .save {r4, r5, r7, lr}
; BASE-THUMB-NEXT: push {r4, r5, r7, lr}
; BASE-THUMB-NEXT: .pad #8
; BASE-THUMB-NEXT: sub sp, #8
; BASE-THUMB-NEXT: uxth r5, r0
; BASE-THUMB-NEXT: mov r4, r1
; BASE-THUMB-NEXT: mov r0, r5
; BASE-THUMB-NEXT: mov r1, r5
; BASE-THUMB-NEXT: blx r4
; BASE-THUMB-NEXT: uxth r1, r0
; BASE-THUMB-NEXT: strh.w r0, [sp, #6]
; BASE-THUMB-NEXT: mov r0, r5
; BASE-THUMB-NEXT: blx r4
; BASE-THUMB-NEXT: ldrh.w r0, [sp, #6]
; BASE-THUMB-NEXT: add sp, #8
; BASE-THUMB-NEXT: pop {r4, r5, r7, pc}
;
; FULLFP16-ARM-LABEL: test_fncall_soft:
; FULLFP16-ARM: @ %bb.0:
; FULLFP16-ARM-NEXT: .save {r4, r5, r11, lr}
; FULLFP16-ARM-NEXT: push {r4, r5, r11, lr}
; FULLFP16-ARM-NEXT: .vsave {d8}
; FULLFP16-ARM-NEXT: vpush {d8}
; FULLFP16-ARM-NEXT: vmov.f16 s0, r0
; FULLFP16-ARM-NEXT: mov r4, r1
; FULLFP16-ARM-NEXT: vmov.f16 r5, s0
; FULLFP16-ARM-NEXT: mov r0, r5
; FULLFP16-ARM-NEXT: mov r1, r5
; FULLFP16-ARM-NEXT: blx r4
; FULLFP16-ARM-NEXT: vmov.f16 s16, r0
; FULLFP16-ARM-NEXT: mov r0, r5
; FULLFP16-ARM-NEXT: vmov.f16 r1, s16
; FULLFP16-ARM-NEXT: blx r4
; FULLFP16-ARM-NEXT: vmov r0, s16
; FULLFP16-ARM-NEXT: vpop {d8}
; FULLFP16-ARM-NEXT: pop {r4, r5, r11, pc}
;
; FULLFP16-THUMB-LABEL: test_fncall_soft:
; FULLFP16-THUMB: @ %bb.0:
; FULLFP16-THUMB-NEXT: .save {r4, r5, r7, lr}
; FULLFP16-THUMB-NEXT: push {r4, r5, r7, lr}
; FULLFP16-THUMB-NEXT: .vsave {d8}
; FULLFP16-THUMB-NEXT: vpush {d8}
; FULLFP16-THUMB-NEXT: vmov.f16 s0, r0
; FULLFP16-THUMB-NEXT: mov r4, r1
; FULLFP16-THUMB-NEXT: vmov.f16 r5, s0
; FULLFP16-THUMB-NEXT: mov r0, r5
; FULLFP16-THUMB-NEXT: mov r1, r5
; FULLFP16-THUMB-NEXT: blx r4
; FULLFP16-THUMB-NEXT: vmov.f16 s16, r0
; FULLFP16-THUMB-NEXT: mov r0, r5
; FULLFP16-THUMB-NEXT: vmov.f16 r1, s16
; FULLFP16-THUMB-NEXT: blx r4
; FULLFP16-THUMB-NEXT: vmov r0, s16
; FULLFP16-THUMB-NEXT: vpop {d8}
; FULLFP16-THUMB-NEXT: pop {r4, r5, r7, pc}
%call = tail call bfloat %f(bfloat %bf, bfloat %bf)
%call1 = tail call bfloat %f(bfloat %bf, bfloat %call)
ret bfloat %call
}
define arm_aapcs_vfpcc bfloat @test_fncall_hard(bfloat %bf, bfloat (bfloat, bfloat)* %f) {
; BASE-ARM-LABEL: test_fncall_hard:
; BASE-ARM: @ %bb.0:
; BASE-ARM-NEXT: .save {r4, lr}
; BASE-ARM-NEXT: push {r4, lr}
; BASE-ARM-NEXT: .vsave {d8}
; BASE-ARM-NEXT: vpush {d8}
; BASE-ARM-NEXT: .pad #8
; BASE-ARM-NEXT: sub sp, sp, #8
; BASE-ARM-NEXT: mov r4, r0
; BASE-ARM-NEXT: vmov r0, s0
; BASE-ARM-NEXT: uxth r0, r0
; BASE-ARM-NEXT: vmov s16, r0
; BASE-ARM-NEXT: vmov.f32 s0, s16
; BASE-ARM-NEXT: vmov.f32 s1, s16
; BASE-ARM-NEXT: blx r4
; BASE-ARM-NEXT: vmov r0, s0
; BASE-ARM-NEXT: vmov.f32 s0, s16
; BASE-ARM-NEXT: strh r0, [sp, #6]
; BASE-ARM-NEXT: uxth r0, r0
; BASE-ARM-NEXT: vmov s1, r0
; BASE-ARM-NEXT: blx r4
; BASE-ARM-NEXT: ldrh r0, [sp, #6]
; BASE-ARM-NEXT: vmov s0, r0
; BASE-ARM-NEXT: add sp, sp, #8
; BASE-ARM-NEXT: vpop {d8}
; BASE-ARM-NEXT: pop {r4, pc}
;
; BASE-THUMB-LABEL: test_fncall_hard:
; BASE-THUMB: @ %bb.0:
; BASE-THUMB-NEXT: .save {r4, lr}
; BASE-THUMB-NEXT: push {r4, lr}
; BASE-THUMB-NEXT: .vsave {d8}
; BASE-THUMB-NEXT: vpush {d8}
; BASE-THUMB-NEXT: .pad #8
; BASE-THUMB-NEXT: sub sp, #8
; BASE-THUMB-NEXT: mov r4, r0
; BASE-THUMB-NEXT: vmov r0, s0
; BASE-THUMB-NEXT: uxth r0, r0
; BASE-THUMB-NEXT: vmov s16, r0
; BASE-THUMB-NEXT: vmov.f32 s0, s16
; BASE-THUMB-NEXT: vmov.f32 s1, s16
; BASE-THUMB-NEXT: blx r4
; BASE-THUMB-NEXT: vmov r0, s0
; BASE-THUMB-NEXT: vmov.f32 s0, s16
; BASE-THUMB-NEXT: strh.w r0, [sp, #6]
; BASE-THUMB-NEXT: uxth r0, r0
; BASE-THUMB-NEXT: vmov s1, r0
; BASE-THUMB-NEXT: blx r4
; BASE-THUMB-NEXT: ldrh.w r0, [sp, #6]
; BASE-THUMB-NEXT: vmov s0, r0
; BASE-THUMB-NEXT: add sp, #8
; BASE-THUMB-NEXT: vpop {d8}
; BASE-THUMB-NEXT: pop {r4, pc}
;
; FULLFP16-LABEL: test_fncall_hard:
; FULLFP16: @ %bb.0:
; FULLFP16-NEXT: .save {r4, lr}
; FULLFP16-NEXT: push {r4, lr}
; FULLFP16-NEXT: .vsave {d8, d9}
; FULLFP16-NEXT: vpush {d8, d9}
; FULLFP16-NEXT: mov r4, r0
; FULLFP16-NEXT: vmov.f16 r0, s0
; FULLFP16-NEXT: vmov s16, r0
; FULLFP16-NEXT: vmov.f32 s0, s16
; FULLFP16-NEXT: vmov.f32 s1, s16
; FULLFP16-NEXT: blx r4
; FULLFP16-NEXT: vmov.f16 r0, s0
; FULLFP16-NEXT: vmov.f32 s18, s0
; FULLFP16-NEXT: vmov.f32 s0, s16
; FULLFP16-NEXT: vmov s1, r0
; FULLFP16-NEXT: blx r4
; FULLFP16-NEXT: vmov.f32 s0, s18
; FULLFP16-NEXT: vpop {d8, d9}
; FULLFP16-NEXT: pop {r4, pc}
%call = tail call arm_aapcs_vfpcc bfloat %f(bfloat %bf, bfloat %bf)
%call1 = tail call arm_aapcs_vfpcc bfloat %f(bfloat %bf, bfloat %call)
ret bfloat %call
}