From: Andrew Waterman Date: Wed, 1 Feb 2017 03:48:41 +0000 (-0800) Subject: Test qNaN and sNaN inputs to FP comparisons X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4e820b5a0007d5ca8ab1a5de2327d247a81a9aa;p=riscv-tests.git Test qNaN and sNaN inputs to FP comparisons --- diff --git a/isa/macros/scalar/test_macros.h b/isa/macros/scalar/test_macros.h index 11645fe..fb89d1e 100644 --- a/isa/macros/scalar/test_macros.h +++ b/isa/macros/scalar/test_macros.h @@ -466,12 +466,12 @@ test_ ## testnum: \ TEST_FP_OP_D_INTERNAL( testnum, flags, dword result, val1, 0.0, 0.0, \ inst a0, f0, rm) -#define TEST_FP_CMP_OP_S( testnum, inst, result, val1, val2 ) \ - TEST_FP_OP_S_INTERNAL( testnum, 0, word result, val1, val2, 0.0, \ +#define TEST_FP_CMP_OP_S( testnum, inst, flags, result, val1, val2 ) \ + TEST_FP_OP_S_INTERNAL( testnum, flags, word result, val1, val2, 0.0, \ inst a0, f0, f1) -#define TEST_FP_CMP_OP_D( testnum, inst, result, val1, val2 ) \ - TEST_FP_OP_D_INTERNAL( testnum, 0, dword result, val1, val2, 0.0, \ +#define TEST_FP_CMP_OP_D( testnum, inst, flags, result, val1, val2 ) \ + TEST_FP_OP_D_INTERNAL( testnum, flags, dword result, val1, val2, 0.0, \ inst a0, f0, f1) #define TEST_FCLASS_S(testnum, correct, input) \ diff --git a/isa/rv64ud/fcmp.S b/isa/rv64ud/fcmp.S index 173dc88..13bd39b 100644 --- a/isa/rv64ud/fcmp.S +++ b/isa/rv64ud/fcmp.S @@ -17,13 +17,26 @@ RVTEST_CODE_BEGIN # Arithmetic tests #------------------------------------------------------------- - TEST_FP_CMP_OP_D( 2, feq.d, 1, -1.36, -1.36) - TEST_FP_CMP_OP_D( 3, fle.d, 1, -1.36, -1.36) - TEST_FP_CMP_OP_D( 4, flt.d, 0, -1.36, -1.36) - - TEST_FP_CMP_OP_D( 5, feq.d, 0, -1.37, -1.36) - TEST_FP_CMP_OP_D( 6, fle.d, 1, -1.37, -1.36) - TEST_FP_CMP_OP_D( 7, flt.d, 1, -1.37, -1.36) + TEST_FP_CMP_OP_D( 2, feq.d, 0x00, 1, -1.36, -1.36) + TEST_FP_CMP_OP_D( 3, fle.d, 0x00, 1, -1.36, -1.36) + TEST_FP_CMP_OP_D( 4, flt.d, 0x00, 0, -1.36, -1.36) + + TEST_FP_CMP_OP_D( 5, feq.d, 0x00, 0, -1.37, -1.36) + TEST_FP_CMP_OP_D( 6, fle.d, 0x00, 1, -1.37, -1.36) + TEST_FP_CMP_OP_D( 7, flt.d, 0x00, 1, -1.37, -1.36) + + # Only sNaN should signal invalid for feq. + TEST_FP_CMP_OP_D( 8, feq.d, 0x00, 0, NaN, 0) + TEST_FP_CMP_OP_D( 9, feq.d, 0x00, 0, NaN, NaN) + TEST_FP_CMP_OP_D(10, feq.d, 0x10, 0, 0d:7ff0000000000001, 0) + + # qNaN should signal invalid for fle/flt. + TEST_FP_CMP_OP_D(11, flt.d, 0x10, 0, NaN, 0) + TEST_FP_CMP_OP_D(12, flt.d, 0x10, 0, NaN, NaN) + TEST_FP_CMP_OP_D(13, flt.d, 0x10, 0, 0d:7ff0000000000001, 0) + TEST_FP_CMP_OP_D(14, fle.d, 0x10, 0, NaN, 0) + TEST_FP_CMP_OP_D(15, fle.d, 0x10, 0, NaN, NaN) + TEST_FP_CMP_OP_D(16, fle.d, 0x10, 0, 0d:7ff0000000000001, 0) TEST_PASSFAIL diff --git a/isa/rv64uf/fcmp.S b/isa/rv64uf/fcmp.S index 24b08c7..e77ca52 100644 --- a/isa/rv64uf/fcmp.S +++ b/isa/rv64uf/fcmp.S @@ -17,13 +17,26 @@ RVTEST_CODE_BEGIN # Arithmetic tests #------------------------------------------------------------- - TEST_FP_CMP_OP_S( 2, feq.s, 1, -1.36, -1.36) - TEST_FP_CMP_OP_S( 3, fle.s, 1, -1.36, -1.36) - TEST_FP_CMP_OP_S( 4, flt.s, 0, -1.36, -1.36) - - TEST_FP_CMP_OP_S( 5, feq.s, 0, -1.37, -1.36) - TEST_FP_CMP_OP_S( 6, fle.s, 1, -1.37, -1.36) - TEST_FP_CMP_OP_S( 7, flt.s, 1, -1.37, -1.36) + TEST_FP_CMP_OP_S( 2, feq.s, 0x00, 1, -1.36, -1.36) + TEST_FP_CMP_OP_S( 3, fle.s, 0x00, 1, -1.36, -1.36) + TEST_FP_CMP_OP_S( 4, flt.s, 0x00, 0, -1.36, -1.36) + + TEST_FP_CMP_OP_S( 5, feq.s, 0x00, 0, -1.37, -1.36) + TEST_FP_CMP_OP_S( 6, fle.s, 0x00, 1, -1.37, -1.36) + TEST_FP_CMP_OP_S( 7, flt.s, 0x00, 1, -1.37, -1.36) + + # Only sNaN should signal invalid for feq. + TEST_FP_CMP_OP_S( 8, feq.s, 0x00, 0, NaN, 0) + TEST_FP_CMP_OP_S( 9, feq.s, 0x00, 0, NaN, NaN) + TEST_FP_CMP_OP_S(10, feq.s, 0x10, 0, 0f:7f800001, 0) + + # qNaN should signal invalid for fle/flt. + TEST_FP_CMP_OP_S(11, flt.s, 0x10, 0, NaN, 0) + TEST_FP_CMP_OP_S(12, flt.s, 0x10, 0, NaN, NaN) + TEST_FP_CMP_OP_S(13, flt.s, 0x10, 0, 0f:7f800001, 0) + TEST_FP_CMP_OP_S(14, fle.s, 0x10, 0, NaN, 0) + TEST_FP_CMP_OP_S(15, fle.s, 0x10, 0, NaN, NaN) + TEST_FP_CMP_OP_S(16, fle.s, 0x10, 0, 0f:7f800001, 0) TEST_PASSFAIL