Add another recoding test case
[riscv-tests.git] / isa / rv64uf / recoding.S
1 # See LICENSE for license details.
2
3 #*****************************************************************************
4 # recoding.S
5 #-----------------------------------------------------------------------------
6 #
7 # Test corner cases of John Hauser's microarchitectural recoding scheme.
8 # There are twice as many recoded values as IEEE-754 values; some of these
9 # extras are redundant (e.g. Inf) and others are illegal (subnormals with
10 # too many bits set).
11 #
12
13 #include "riscv_test.h"
14 #include "test_macros.h"
15
16 RVTEST_RV64UF
17 RVTEST_CODE_BEGIN
18
19 # Make sure infinities with different mantissas compare as equal.
20 flw f0, minf, a0
21 flw f1, three, a0
22 fmul.s f1, f1, f0
23 TEST_CASE( 2, a0, 1, feq.s a0, f0, f1)
24 TEST_CASE( 3, a0, 1, fle.s a0, f0, f1)
25 TEST_CASE( 4, a0, 0, flt.s a0, f0, f1)
26
27 # When converting small doubles to single-precision subnormals,
28 # ensure that the extra precision is discarded.
29 flw f0, big, a0
30 fld f1, tiny, a0
31 fcvt.s.d f1, f1
32 fmul.s f0, f0, f1
33 fmv.x.s a0, f0
34 lw a1, small
35 TEST_CASE(10, a0, 0, sub a0, a0, a1)
36
37 # Make sure FSD+FLD correctly saves and restores a single-precision value.
38 flw f0, three, a0
39 fadd.s f1, f0, f0
40 fadd.s f0, f0, f0
41 fsd f0, tiny, a0
42 fld f0, tiny, a0
43 TEST_CASE(20, a0, 1, feq.s a0, f0, f1)
44
45 TEST_PASSFAIL
46
47 RVTEST_CODE_END
48
49 .data
50 RVTEST_DATA_BEGIN
51
52 minf: .float -Inf
53 three: .float 3.0
54 big: .float 1221
55 small: .float 2.9133121e-37
56 tiny: .double 2.3860049081905093e-40
57
58 RVTEST_DATA_END