Repository navigation
Expand file tree
/
Copy pathvector_fp_convert.S
More file actions
442 lines (433 loc) · 19.2 KB
/
Copy pathvector_fp_convert.S
File metadata and controls
442 lines (433 loc) · 19.2 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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# Vector floating-point conversions and accrued flags.
.noshrink
# Enable FS and VS and select RNE.
.4byte 0x000062b7 # lui t0, 0x6
.4byte 0x60028293 # addi t0, t0, 0x600
.4byte 0x3002a073 # csrs mstatus, t0
.4byte 0x00305073 # csrwi fcsr, 0
# Binary32 fractions exercise signed and unsigned rounding to integers.
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x403002b7 # lui t0, 0x40300
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a801c57 # vfcvt.xu.f.v v24, v8
.assert trap == 0 "vfcvt.xu.f.v retires"
.4byte 0x43802557 # vmv.x.s a0, v24
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a831857 # vfcvt.rtz.xu.f.v v16, v8
.assert trap == 0 "vfcvt.rtz.xu.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x2 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc03002b7 # lui t0, 0xc0300
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a809857 # vfcvt.x.f.v v16, v8
.assert trap == 0 "vfcvt.x.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffd "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a839857 # vfcvt.rtz.x.f.v v16, v8
.assert trap == 0 "vfcvt.rtz.x.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffe "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# Binary32 conversion of an integer with its top bit and low bit set.
.4byte 0x800002b7 # lui t0, 0x80000
.4byte 0x00128293 # addi t0, t0, 1
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a811857 # vfcvt.f.xu.v v16, v8
.assert trap == 0 "vfcvt.f.xu.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x4f000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a819857 # vfcvt.f.x.v v16, v8
.assert trap == 0 "vfcvt.f.x.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xffffffffcf000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# Binary64 fractions exercise signed and unsigned rounding to integers.
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x400602b7 # lui t0, 0x40060
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a801857 # vfcvt.xu.f.v v16, v8
.assert trap == 0 "vfcvt.xu.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a831857 # vfcvt.rtz.xu.f.v v16, v8
.assert trap == 0 "vfcvt.rtz.xu.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x2 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc00602b7 # lui t0, 0xc0060
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a809857 # vfcvt.x.f.v v16, v8
.assert trap == 0 "vfcvt.x.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffd "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a839857 # vfcvt.rtz.x.f.v v16, v8
.assert trap == 0 "vfcvt.rtz.x.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffe "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# Binary64 conversion of an integer with its top bit and low bit set.
.4byte 0x800002b7 # lui t0, 0x80000
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x00100313 # addi t1, zero, 1
.4byte 0x0062e2b3 # or t0, t0, t1
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a811857 # vfcvt.f.xu.v v16, v8
.assert trap == 0 "vfcvt.f.xu.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x43e0000000000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a819857 # vfcvt.f.x.v v16, v8
.assert trap == 0 "vfcvt.f.x.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xc3e0000000000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# Widen binary32 and 32-bit integers into 64-bit destinations.
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x403002b7 # lui t0, 0x40300
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a841857 # vfwcvt.xu.f.v v16, v8
.assert trap == 0 "vfwcvt.xu.f.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a871857 # vfwcvt.rtz.xu.f.v v16, v8
.assert trap == 0 "vfwcvt.rtz.xu.f.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x2 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0xc03002b7 # lui t0, 0xc0300
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a849857 # vfwcvt.x.f.v v16, v8
.assert trap == 0 "vfwcvt.x.f.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffd "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a879857 # vfwcvt.rtz.x.f.v v16, v8
.assert trap == 0 "vfwcvt.rtz.x.f.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffe "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a861857 # vfwcvt.f.f.v v16, v8
.assert trap == 0 "vfwcvt.f.f.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xc006000000000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x0 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x800002b7 # lui t0, 0x80000
.4byte 0x00128293 # addi t0, t0, 1
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a851857 # vfwcvt.f.xu.v v16, v8
.assert trap == 0 "vfwcvt.f.xu.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x41e0000000200000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x0 "conversion flags"
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a859857 # vfwcvt.f.x.v v16, v8
.assert trap == 0 "vfwcvt.f.x.v retires"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xc1dfffffffc00000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x0 "conversion flags"
# Narrow 64-bit fractions and integers into 32-bit destinations.
.4byte 0x400602b7 # lui t0, 0x40060
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a881857 # vfncvt.xu.f.w v16, v8
.assert trap == 0 "vfncvt.xu.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a8b1857 # vfncvt.rtz.xu.f.w v16, v8
.assert trap == 0 "vfncvt.rtz.xu.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x2 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0xc00602b7 # lui t0, 0xc0060
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a889857 # vfncvt.x.f.w v16, v8
.assert trap == 0 "vfncvt.x.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffd "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a8b9857 # vfncvt.rtz.x.f.w v16, v8
.assert trap == 0 "vfncvt.rtz.x.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xfffffffffffffffe "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x800002b7 # lui t0, 0x80000
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x00100313 # addi t1, zero, 1
.4byte 0x0062e2b3 # or t0, t0, t1
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a891857 # vfncvt.f.xu.w v16, v8
.assert trap == 0 "vfncvt.f.xu.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x5f000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a899857 # vfncvt.f.x.w v16, v8
.assert trap == 0 "vfncvt.f.x.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0xffffffffdf000000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# A halfway value separates nearest-even from round-to-odd narrowing.
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x3ff002b7 # lui t0, 0x3ff00
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x10000337 # lui t1, 0x10000
.4byte 0x0062e2b3 # or t0, t0, t1
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a8a1857 # vfncvt.f.f.w v16, v8
.assert trap == 0 "vfncvt.f.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3f800000 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a8a9857 # vfncvt.rod.f.f.w v16, v8
.assert trap == 0 "vfncvt.rod.f.f.w retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x3f800001 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x1 "conversion flags"
# Narrow a finite binary64 value outside the binary32 range.
.4byte 0xc1817657 # vsetivli a2, 2, e64, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x47f002b7 # lui t0, 0x47f00
.4byte 0x02029293 # slli t0, t0, 32
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0xc1017657 # vsetivli a2, 2, e32, m1, tu, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a8a1857 # vfncvt.f.f.w v16, v8
.assert trap == 0 "narrowing overflow retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "narrowed element writes x10"
.assert rd_wdata == 0x7f800000 "narrowing overflow rounds to positive infinity"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "narrowing flags write x11"
.assert rd_wdata == 0x5 "narrowing overflow sets OF and NX"
# A negative input converts to unsigned zero and raises invalid.
.4byte 0xbf8002b7 # lui t0, 0xbf800
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x4a801857 # vfcvt.xu.f.v v16, v8
.assert trap == 0 "vfcvt.xu.f.v retires"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x0 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x10 "conversion flags"
# The guard selects the finite first lane and preserves the second lane.
.4byte 0x7fc002b7 # lui t0, 0x7fc00
.4byte 0x5e02c457 # vmv.v.x v8, t0
.4byte 0x3f8002b7 # lui t0, 0x3f800
.4byte 0x4202e457 # vmv.s.x v8, t0
.4byte 0x00100293 # addi t0, zero, 1
.4byte 0x4202e057 # vmv.s.x v0, t0
.4byte 0xc5017657 # vsetivli a2, 2, e32, m1, ta, mu
.assert rd_addr == 12 "active vector length writes x12"
.assert rd_wdata == 0x2 "active vector length"
.4byte 0x05500293 # addi t0, zero, 0x55
.4byte 0x5e02c857 # vmv.v.x v16, t0
.4byte 0x00105073 # csrwi fflags, 0
.4byte 0x48809857 # vfcvt.x.f.v v16, v8, v0.t
.assert trap == 0 "masked conversion retires"
.4byte 0x3f00ba57 # vslidedown.vi v20, v16, 1
.4byte 0x43402557 # vmv.x.s a0, v20
.assert rd_addr == 10 "preserved element writes x10"
.assert rd_wdata == 0x55 "masked-off element keeps its original value"
.4byte 0x43002557 # vmv.x.s a0, v16
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x1 "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x0 "conversion flags"
# The unmasked conversion defines the result for the NaN lane.
.4byte 0x4a809857 # vfcvt.x.f.v v16, v8
.assert trap == 0 "unmasked conversion retires"
.4byte 0x3f00ba57 # vslidedown.vi v20, v16, 1
.4byte 0x43402557 # vmv.x.s a0, v20
.assert rd_addr == 10 "converted element writes x10"
.assert rd_wdata == 0x7fffffff "converted element"
.4byte 0x001025f3 # csrr a1, fflags
.assert rd_addr == 11 "conversion flags writes x11"
.assert rd_wdata == 0x10 "conversion flags"