fp16-promote.ll
11.5 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=sparc-linux-gnu < %s | FileCheck %s -check-prefix=V8 -check-prefix=V8-BE
; RUN: llc -mtriple=sparcel-linux-gnu < %s | FileCheck %s -check-prefix=V8 -check-prefix=V8-EL
; RUN: llc -mtriple=sparc-linux-gnu -O0 < %s | FileCheck %s -check-prefix=V8-UNOPT
; RUN: llc -mtriple=sparc-linux-gnu -mattr=v9 < %s | FileCheck %s -check-prefix=V9
; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefix=SPARC64
define void @test_load_store(half* %p, half* %q) nounwind {
; V8-LABEL: test_load_store:
; V8: ! %bb.0:
; V8-NEXT: lduh [%o0], %o0
; V8-NEXT: retl
; V8-NEXT: sth %o0, [%o1]
;
; V8-UNOPT-LABEL: test_load_store:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: lduh [%o0], %o0
; V8-UNOPT-NEXT: retl
; V8-UNOPT-NEXT: sth %o0, [%o1]
;
; V9-LABEL: test_load_store:
; V9: ! %bb.0:
; V9-NEXT: lduh [%o0], %o0
; V9-NEXT: retl
; V9-NEXT: sth %o0, [%o1]
;
; SPARC64-LABEL: test_load_store:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: lduh [%o0], %o0
; SPARC64-NEXT: retl
; SPARC64-NEXT: sth %o0, [%o1]
%a = load half, half* %p
store half %a, half* %q
ret void
}
define float @test_fpextend_float(half* %p) nounwind {
; V8-LABEL: test_fpextend_float:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -96, %sp
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i0], %o0
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fpextend_float:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -96, %sp
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fpextend_float:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -96, %sp
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i0], %o0
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fpextend_float:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -176, %sp
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i0], %o0
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = load half, half* %p
%r = fpext half %a to float
ret float %r
}
define double @test_fpextend_double(half* %p) nounwind {
; V8-LABEL: test_fpextend_double:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -96, %sp
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i0], %o0
; V8-NEXT: fstod %f0, %f0
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fpextend_double:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -96, %sp
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: fstod %f0, %f0
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fpextend_double:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -96, %sp
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i0], %o0
; V9-NEXT: fstod %f0, %f0
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fpextend_double:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -176, %sp
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i0], %o0
; SPARC64-NEXT: fstod %f0, %f0
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = load half, half* %p
%r = fpext half %a to double
ret double %r
}
define void @test_fptrunc_float(float %f, half* %p) nounwind {
; V8-LABEL: test_fptrunc_float:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -96, %sp
; V8-NEXT: call __gnu_f2h_ieee
; V8-NEXT: mov %i0, %o0
; V8-NEXT: sth %o0, [%i1]
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fptrunc_float:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -104, %sp
; V8-UNOPT-NEXT: st %i0, [%fp+-4]
; V8-UNOPT-NEXT: ld [%fp+-4], %f0
; V8-UNOPT-NEXT: mov %i0, %o0
; V8-UNOPT-NEXT: st %i1, [%fp+-8] ! 4-byte Folded Spill
; V8-UNOPT-NEXT: call __gnu_f2h_ieee
; V8-UNOPT-NEXT: st %f0, [%fp+-12]
; V8-UNOPT-NEXT: ld [%fp+-8], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: sth %o0, [%i0]
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fptrunc_float:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -96, %sp
; V9-NEXT: call __gnu_f2h_ieee
; V9-NEXT: mov %i0, %o0
; V9-NEXT: sth %o0, [%i1]
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fptrunc_float:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -176, %sp
; SPARC64-NEXT: call __gnu_f2h_ieee
; SPARC64-NEXT: nop
; SPARC64-NEXT: sth %o0, [%i1]
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = fptrunc float %f to half
store half %a, half* %p
ret void
}
define void @test_fptrunc_double(double %d, half* %p) nounwind {
; V8-LABEL: test_fptrunc_double:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -112, %sp
; V8-NEXT: ! kill: def $i1 killed $i1 killed $i0_i1 def $i0_i1
; V8-NEXT: ! kill: def $i0 killed $i0 killed $i0_i1 def $i0_i1
; V8-NEXT: std %i0, [%fp+-8]
; V8-NEXT: ldd [%fp+-8], %f0
; V8-NEXT: std %f0, [%fp+-16]
; V8-NEXT: call __truncdfhf2
; V8-NEXT: ldd [%fp+-16], %o0
; V8-NEXT: sth %o0, [%i2]
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fptrunc_double:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -112, %sp
; V8-UNOPT-NEXT: ! implicit-def: $i4_i5
; V8-UNOPT-NEXT: mov %i0, %i4
; V8-UNOPT-NEXT: mov %i1, %i5
; V8-UNOPT-NEXT: std %i4, [%fp+-8]
; V8-UNOPT-NEXT: ldd [%fp+-8], %f0
; V8-UNOPT-NEXT: std %f0, [%fp+-16]
; V8-UNOPT-NEXT: ldd [%fp+-16], %i4
; V8-UNOPT-NEXT: mov %i4, %i0
; V8-UNOPT-NEXT: ! kill: def $i5 killed $i5 killed $i4_i5
; V8-UNOPT-NEXT: mov %i0, %o0
; V8-UNOPT-NEXT: mov %i5, %o1
; V8-UNOPT-NEXT: call __truncdfhf2
; V8-UNOPT-NEXT: st %i2, [%fp+-20]
; V8-UNOPT-NEXT: ld [%fp+-20], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: sth %o0, [%i0]
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fptrunc_double:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -112, %sp
; V9-NEXT: ! kill: def $i1 killed $i1 killed $i0_i1 def $i0_i1
; V9-NEXT: ! kill: def $i0 killed $i0 killed $i0_i1 def $i0_i1
; V9-NEXT: std %i0, [%fp+-8]
; V9-NEXT: ldd [%fp+-8], %f0
; V9-NEXT: std %f0, [%fp+-16]
; V9-NEXT: call __truncdfhf2
; V9-NEXT: ldd [%fp+-16], %o0
; V9-NEXT: sth %o0, [%i2]
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fptrunc_double:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -176, %sp
; SPARC64-NEXT: call __truncdfhf2
; SPARC64-NEXT: nop
; SPARC64-NEXT: sth %o0, [%i1]
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = fptrunc double %d to half
store half %a, half* %p
ret void
}
define void @test_fadd(half* %p, half* %q) nounwind {
; V8-LABEL: test_fadd:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -104, %sp
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i0], %o0
; V8-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i1], %o0
; V8-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
; V8-NEXT: fadds %f1, %f0, %f0
; V8-NEXT: st %f0, [%fp+-4]
; V8-NEXT: call __gnu_f2h_ieee
; V8-NEXT: ld [%fp+-4], %o0
; V8-NEXT: sth %o0, [%i0]
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fadd:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -112, %sp
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: st %i1, [%fp+-8] ! 4-byte Folded Spill
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: st %i0, [%fp+-12]
; V8-UNOPT-NEXT: ld [%fp+-8], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: st %f0, [%fp+-16]
; V8-UNOPT-NEXT: ld [%fp+-16], %f1 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: fadds %f1, %f0, %f0
; V8-UNOPT-NEXT: st %f0, [%fp+-4]
; V8-UNOPT-NEXT: call __gnu_f2h_ieee
; V8-UNOPT-NEXT: ld [%fp+-4], %o0
; V8-UNOPT-NEXT: ld [%fp+-12], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: sth %o0, [%i0]
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fadd:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -104, %sp
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i0], %o0
; V9-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i1], %o0
; V9-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
; V9-NEXT: fadds %f1, %f0, %f0
; V9-NEXT: st %f0, [%fp+-4]
; V9-NEXT: call __gnu_f2h_ieee
; V9-NEXT: ld [%fp+-4], %o0
; V9-NEXT: sth %o0, [%i0]
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fadd:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -192, %sp
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i0], %o0
; SPARC64-NEXT: st %f0, [%fp+2043] ! 4-byte Folded Spill
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i1], %o0
; SPARC64-NEXT: ld [%fp+2043], %f1 ! 4-byte Folded Reload
; SPARC64-NEXT: call __gnu_f2h_ieee
; SPARC64-NEXT: fadds %f1, %f0, %f1
; SPARC64-NEXT: sth %o0, [%i0]
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = load half, half* %p
%b = load half, half* %q
%r = fadd half %a, %b
store half %r, half* %p
ret void
}
define void @test_fmul(half* %p, half* %q) nounwind {
; V8-LABEL: test_fmul:
; V8: ! %bb.0:
; V8-NEXT: save %sp, -104, %sp
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i0], %o0
; V8-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
; V8-NEXT: call __gnu_h2f_ieee
; V8-NEXT: lduh [%i1], %o0
; V8-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
; V8-NEXT: fmuls %f1, %f0, %f0
; V8-NEXT: st %f0, [%fp+-4]
; V8-NEXT: call __gnu_f2h_ieee
; V8-NEXT: ld [%fp+-4], %o0
; V8-NEXT: sth %o0, [%i0]
; V8-NEXT: ret
; V8-NEXT: restore
;
; V8-UNOPT-LABEL: test_fmul:
; V8-UNOPT: ! %bb.0:
; V8-UNOPT-NEXT: save %sp, -112, %sp
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: st %i1, [%fp+-8] ! 4-byte Folded Spill
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: st %i0, [%fp+-12]
; V8-UNOPT-NEXT: ld [%fp+-8], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: lduh [%i0], %o0
; V8-UNOPT-NEXT: call __gnu_h2f_ieee
; V8-UNOPT-NEXT: st %f0, [%fp+-16]
; V8-UNOPT-NEXT: ld [%fp+-16], %f1 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: fmuls %f1, %f0, %f0
; V8-UNOPT-NEXT: st %f0, [%fp+-4]
; V8-UNOPT-NEXT: call __gnu_f2h_ieee
; V8-UNOPT-NEXT: ld [%fp+-4], %o0
; V8-UNOPT-NEXT: ld [%fp+-12], %i0 ! 4-byte Folded Reload
; V8-UNOPT-NEXT: sth %o0, [%i0]
; V8-UNOPT-NEXT: ret
; V8-UNOPT-NEXT: restore
;
; V9-LABEL: test_fmul:
; V9: ! %bb.0:
; V9-NEXT: save %sp, -104, %sp
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i0], %o0
; V9-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
; V9-NEXT: call __gnu_h2f_ieee
; V9-NEXT: lduh [%i1], %o0
; V9-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
; V9-NEXT: fmuls %f1, %f0, %f0
; V9-NEXT: st %f0, [%fp+-4]
; V9-NEXT: call __gnu_f2h_ieee
; V9-NEXT: ld [%fp+-4], %o0
; V9-NEXT: sth %o0, [%i0]
; V9-NEXT: ret
; V9-NEXT: restore
;
; SPARC64-LABEL: test_fmul:
; SPARC64: ! %bb.0:
; SPARC64-NEXT: save %sp, -192, %sp
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i0], %o0
; SPARC64-NEXT: st %f0, [%fp+2043] ! 4-byte Folded Spill
; SPARC64-NEXT: call __gnu_h2f_ieee
; SPARC64-NEXT: lduh [%i1], %o0
; SPARC64-NEXT: ld [%fp+2043], %f1 ! 4-byte Folded Reload
; SPARC64-NEXT: call __gnu_f2h_ieee
; SPARC64-NEXT: fmuls %f1, %f0, %f1
; SPARC64-NEXT: sth %o0, [%i0]
; SPARC64-NEXT: ret
; SPARC64-NEXT: restore
%a = load half, half* %p
%b = load half, half* %q
%r = fmul half %a, %b
store half %r, half* %p
ret void
}