Test FMIN/FMAX NaN behavior
authorAndrew Waterman <andrew@sifive.com>
Thu, 2 Feb 2017 07:17:17 +0000 (23:17 -0800)
committerAndrew Waterman <andrew@sifive.com>
Thu, 2 Feb 2017 07:17:17 +0000 (23:17 -0800)
See https://github.com/riscv/riscv-isa-sim/issues/76

isa/macros/scalar/test_macros.h
isa/rv64ud/fmin.S
isa/rv64uf/fmin.S

index fb89d1e2d3b8787c8ff47512646028739737b32e..006f4193a26793501f51032cc4ccce0d0df59d4c 100644 (file)
@@ -374,6 +374,11 @@ test_ ## testnum: \
 # Tests floating-point instructions
 #-----------------------------------------------------------------------
 
+#define qNaNf 0f:7fc00000
+#define sNaNf 0f:7f800001
+#define qNaN 0d:7ff8000000000000
+#define sNaN 0d:7ff0000000000001
+
 #define TEST_FP_OP_S_INTERNAL( testnum, flags, result, val1, val2, val3, code... ) \
 test_ ## testnum: \
   li  TESTNUM, testnum; \
index 82641bce91e2aa1b5fcc219294189fe3196fb3cf..64c4aac0b21adaa997951c1cf95c3fe12f6b7cf9 100644 (file)
@@ -31,6 +31,11 @@ RVTEST_CODE_BEGIN
   TEST_FP_OP2_D(16,  fmax.d, 0, 3.14159265, 3.14159265, 0.00000001 );
   TEST_FP_OP2_D(17,  fmax.d, 0,       -1.0,       -1.0,       -2.0 );
 
+  # FMIN(sNaN, x) = canonical NaN
+  TEST_FP_OP2_D(20,  fmax.d, 0x10, qNaN, sNaN, 0);
+  # FMIN(qNaN, qNaN) = canonical NaN
+  TEST_FP_OP2_D(21,  fmax.d, 0x00, qNaN, NaN, NaN);
+
   TEST_PASSFAIL
 
 RVTEST_CODE_END
index a2650e570e52fee876b7ab610f2ca15e37fedc43..5bbbf3f37ffb655f20da7a76387845b7c68ebb4b 100644 (file)
@@ -31,6 +31,11 @@ RVTEST_CODE_BEGIN
   TEST_FP_OP2_S(16,  fmax.s, 0, 3.14159265, 3.14159265, 0.00000001 );
   TEST_FP_OP2_S(17,  fmax.s, 0,       -1.0,       -1.0,       -2.0 );
 
+  # FMIN(sNaN, x) = canonical NaN
+  TEST_FP_OP2_S(20,  fmax.s, 0x10, qNaNf, sNaNf, 0);
+  # FMIN(qNaN, qNaN) = canonical NaN
+  TEST_FP_OP2_S(21,  fmax.s, 0x00, qNaNf, NaN, NaN);
+
   TEST_PASSFAIL
 
 RVTEST_CODE_END