Test FMIN/FMAX NaN behavior
[riscv-tests.git] / isa / rv64ud / structural.S
1 # See LICENSE for license details.
2
3 #*****************************************************************************
4 # structural.S
5 #-----------------------------------------------------------------------------
6 #
7 # This test verifies that the FPU correctly obviates structural hazards on its
8 # writeback port (e.g. fadd followed by fsgnj)
9 #
10
11 #include "riscv_test.h"
12 #include "test_macros.h"
13
14 RVTEST_RV64UF
15 RVTEST_CODE_BEGIN
16
17 li x25, 1
18
19 li x2, 0x3FF0000000000000
20 li x1, 0x3F800000
21
22 #define TEST(nops, errcode) \
23 fmv.d.x f4, x0 ;\
24 fmv.s.x f3, x0 ;\
25 fmv.d.x f2, x2 ;\
26 fmv.s.x f1, x1 ;\
27 j 1f ;\
28 .align 5 ;\
29 1:fmul.d f4, f2, f2 ;\
30 nops ;\
31 fsgnj.s f3, f1, f1 ;\
32 fmv.x.d x4, f4 ;\
33 fmv.x.s x3, f3 ;\
34 beq x1, x3, 2f ;\
35 RVTEST_FAIL ;\
36 2:beq x2, x4, 2f ;\
37 RVTEST_FAIL; \
38 2:fmv.d.x f2, zero ;\
39 fmv.s.x f1, zero ;\
40
41 TEST(;,2)
42 TEST(nop,4)
43 TEST(nop;nop,6)
44 TEST(nop;nop;nop,8)
45 TEST(nop;nop;nop;nop,10)
46 TEST(nop;nop;nop;nop;nop,12)
47 TEST(nop;nop;nop;nop;nop;nop,14)
48
49 RVTEST_PASS
50
51 RVTEST_CODE_END
52
53 .data
54 RVTEST_DATA_BEGIN
55
56 TEST_DATA
57
58 RVTEST_DATA_END