All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH  v1 0/6] fpu/next, mostly bits s390x tcg will need
@ 2019-02-22 20:44 Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 1/6] tests: Ignore fp test outputs Alex Bennée
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-s390x, Alex Bennée

Hi,

Here is the current status of fpu/next. I intend to send the PR in
next week as there are bits in it blocking work for s390. This is the
last chance to pipe up with any objections.

The following patches need review
  0004/tests fp add wrapping for f128_to_ui32.patch
  0005/tests fp enable f128_to_ui 32 64 tests in float t.patch

Alex Bennée (2):
  tests/fp: add wrapping for f128_to_ui32
  tests/fp: enable f128_to_ui[32/64] tests in float-to-uint

David Hildenbrand (2):
  softfloat: add float128_is_{normal,denormal}
  softfloat: Implement float128_to_uint32

Eric Blake (1):
  tests: Ignore fp test outputs

Richard Henderson (1):
  softfloat: Support float_round_to_odd more places

 fpu/softfloat.c         | 93 ++++++++++++++++++++++++++++++++++++++---
 include/fpu/softfloat.h | 15 ++++++-
 tests/.gitignore        |  1 +
 tests/Makefile.include  |  7 ++--
 tests/fp/fp-test.c      | 46 +++++++++++++++-----
 tests/fp/wrap.inc.c     |  1 +
 6 files changed, 143 insertions(+), 20 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH  v1 1/6] tests: Ignore fp test outputs
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
@ 2019-02-22 20:44 ` Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 2/6] softfloat: add float128_is_{normal, denormal} Alex Bennée
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-s390x, Eric Blake, Emilio G . Cota, Alex Bennée

From: Eric Blake <eblake@redhat.com>

Commit 2cade3d wired up new tests, but did not exclude the
new *.out files produced by running the tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index 72c18aaab0..f2bf85c8c4 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -5,6 +5,7 @@ benchmark-crypto-hmac
 check-*
 !check-*.c
 !check-*.sh
+fp/*.out
 qht-bench
 rcutorture
 test-*
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH  v1 2/6] softfloat: add float128_is_{normal, denormal}
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 1/6] tests: Ignore fp test outputs Alex Bennée
@ 2019-02-22 20:44 ` Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 3/6] softfloat: Implement float128_to_uint32 Alex Bennée
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, David Hildenbrand, Richard Henderson, Alex Bennée

From: David Hildenbrand <david@redhat.com>

Needed on s390x, to test for the data class of a number. So it will
gain soon a user.

A number is considered normal if the exponent is neither 0 nor all 1's.
That can be checked by adding 1 to the exponent, and comparing against
>= 2 after dropping an eventual overflow into the sign bit.

While at it, convert the other floatXX_is_normal functions to use a
similar, less error prone calculation, as suggested by Richard H.

Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/fpu/softfloat.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 38a5e99cf3..3ff5215b81 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -466,7 +466,7 @@ static inline int float32_is_zero_or_denormal(float32 a)
 
 static inline bool float32_is_normal(float32 a)
 {
-    return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000;
+    return (((float32_val(a) >> 23) + 1) & 0xff) >= 2;
 }
 
 static inline bool float32_is_denormal(float32 a)
@@ -622,7 +622,7 @@ static inline int float64_is_zero_or_denormal(float64 a)
 
 static inline bool float64_is_normal(float64 a)
 {
-    return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53;
+    return (((float64_val(a) >> 52) + 1) & 0x7ff) >= 2;
 }
 
 static inline bool float64_is_denormal(float64 a)
@@ -940,6 +940,16 @@ static inline int float128_is_zero_or_denormal(float128 a)
     return (a.high & 0x7fff000000000000LL) == 0;
 }
 
+static inline bool float128_is_normal(float128 a)
+{
+    return (((a.high >> 48) + 1) & 0x7fff) >= 2;
+}
+
+static inline bool float128_is_denormal(float128 a)
+{
+    return float128_is_zero_or_denormal(a) && !float128_is_zero(a);
+}
+
 static inline int float128_is_any_nan(float128 a)
 {
     return ((a.high >> 48) & 0x7fff) == 0x7fff &&
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v1 3/6] softfloat: Implement float128_to_uint32
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 1/6] tests: Ignore fp test outputs Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 2/6] softfloat: add float128_is_{normal, denormal} Alex Bennée
@ 2019-02-22 20:44 ` Alex Bennée
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32 Alex Bennée
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, David Hildenbrand, Richard Henderson, Alex Bennée

From: David Hildenbrand <david@redhat.com>

Handling it just like float128_to_uint32_round_to_zero, that hopefully
is free of bugs :)

Documentation basically copied from float128_to_uint64

Signed-off-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 fpu/softfloat.c         | 29 +++++++++++++++++++++++++++++
 include/fpu/softfloat.h |  1 +
 2 files changed, 30 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 9132d7a0b0..c69cd6b5d1 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -6792,6 +6792,35 @@ uint32_t float128_to_uint32_round_to_zero(float128 a, float_status *status)
     return res;
 }
 
+/*----------------------------------------------------------------------------
+| Returns the result of converting the quadruple-precision floating-point value
+| `a' to the 32-bit unsigned integer format.  The conversion is
+| performed according to the IEC/IEEE Standard for Binary Floating-Point
+| Arithmetic---which means in particular that the conversion is rounded
+| according to the current rounding mode.  If `a' is a NaN, the largest
+| positive integer is returned.  If the conversion overflows, the
+| largest unsigned integer is returned.  If 'a' is negative, the value is
+| rounded and zero is returned; negative values that do not round to zero
+| will raise the inexact exception.
+*----------------------------------------------------------------------------*/
+
+uint32_t float128_to_uint32(float128 a, float_status *status)
+{
+    uint64_t v;
+    uint32_t res;
+    int old_exc_flags = get_float_exception_flags(status);
+
+    v = float128_to_uint64(a, status);
+    if (v > 0xffffffff) {
+        res = 0xffffffff;
+    } else {
+        return v;
+    }
+    set_float_exception_flags(old_exc_flags, status);
+    float_raise(float_flag_invalid, status);
+    return res;
+}
+
 /*----------------------------------------------------------------------------
 | Returns the result of converting the quadruple-precision floating-point
 | value `a' to the single-precision floating-point format.  The conversion
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 3ff5215b81..3ff3fa5224 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -878,6 +878,7 @@ int64_t float128_to_int64(float128, float_status *status);
 int64_t float128_to_int64_round_to_zero(float128, float_status *status);
 uint64_t float128_to_uint64(float128, float_status *status);
 uint64_t float128_to_uint64_round_to_zero(float128, float_status *status);
+uint32_t float128_to_uint32(float128, float_status *status);
 uint32_t float128_to_uint32_round_to_zero(float128, float_status *status);
 float32 float128_to_float32(float128, float_status *status);
 float64 float128_to_float64(float128, float_status *status);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
                   ` (2 preceding siblings ...)
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 3/6] softfloat: Implement float128_to_uint32 Alex Bennée
@ 2019-02-22 20:44 ` Alex Bennée
  2019-02-22 21:40   ` Richard Henderson
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint Alex Bennée
  2019-02-22 20:45 ` [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places Alex Bennée
  5 siblings, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-s390x, Alex Bennée

Needed to test: softfloat: add float128_is_{normal,denormal}

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/fp/fp-test.c  | 3 ++-
 tests/fp/wrap.inc.c | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 2a35ef601d..4114f346a9 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -622,7 +622,8 @@ static void do_testfloat(int op, int rmode, bool exact)
         test_ab_extF80_z_bool(true_ab_extF80M_z_bool, subj_ab_extF80M_z_bool);
         break;
     case F128_TO_UI32:
-        not_implemented();
+        test_a_f128_z_ui32_rx(slow_f128M_to_ui32, qemu_f128M_to_ui32, rmode,
+                              exact);
         break;
     case F128_TO_UI64:
         test_a_f128_z_ui64_rx(slow_f128M_to_ui64, qemu_f128M_to_ui64, rmode,
diff --git a/tests/fp/wrap.inc.c b/tests/fp/wrap.inc.c
index d3bf600cd0..0cbd20013e 100644
--- a/tests/fp/wrap.inc.c
+++ b/tests/fp/wrap.inc.c
@@ -367,6 +367,7 @@ WRAP_80_TO_INT_MINMAG(qemu_extF80M_to_i64_r_minMag,
 WRAP_128_TO_INT(qemu_f128M_to_i32, float128_to_int32, int_fast32_t)
 WRAP_128_TO_INT(qemu_f128M_to_i64, float128_to_int64, int_fast64_t)
 
+WRAP_128_TO_INT(qemu_f128M_to_ui32, float128_to_uint32, uint_fast32_t)
 WRAP_128_TO_INT(qemu_f128M_to_ui64, float128_to_uint64, uint_fast64_t)
 #undef WRAP_128_TO_INT
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
                   ` (3 preceding siblings ...)
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32 Alex Bennée
@ 2019-02-22 20:44 ` Alex Bennée
  2019-02-22 21:40   ` Richard Henderson
  2019-02-22 20:45 ` [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places Alex Bennée
  5 siblings, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-s390x, Alex Bennée

We've just added f128_to_ui32 and we missed out the f128_to_ui64 tests
last time.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/Makefile.include | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 3741f8f6dd..060f765b0e 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -909,8 +909,7 @@ test-softfloat = $(call quiet-command, \
 
 # Conversion Routines:
 # FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
-#        ui32_to_f128 (not implemented), f128_to_ui32 (not implemented)
-#        extF80_roundToInt (broken)
+#        ui32_to_f128 (not implemented), extF80_roundToInt (broken)
 #
 check-softfloat-conv: $(FP_TEST_BIN)
 	$(call test-softfloat, \
@@ -939,9 +938,11 @@ check-softfloat-conv: $(FP_TEST_BIN)
 		f16_to_ui32 f16_to_ui32_r_minMag \
 		f32_to_ui32 f32_to_ui32_r_minMag \
 		f64_to_ui32 f64_to_ui32_r_minMag \
+		f128_to_ui32 f128_to_ui32_r_minMag \
 		f16_to_ui64 f16_to_ui64_r_minMag \
 		f32_to_ui64 f32_to_ui64_r_minMag \
-		f64_to_ui64 f64_to_ui64_r_minMag, \
+		f64_to_ui64 f64_to_ui64_r_minMag \
+		f128_to_ui64 f128_to_ui64_r_minMag, \
 		float-to-uint)
 	$(call test-softfloat, \
 		f16_roundToInt f32_roundToInt \
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places
  2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
                   ` (4 preceding siblings ...)
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint Alex Bennée
@ 2019-02-22 20:45 ` Alex Bennée
  2019-02-22 21:43   ` Richard Henderson
  5 siblings, 1 reply; 13+ messages in thread
From: Alex Bennée @ 2019-02-22 20:45 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-s390x, Richard Henderson, David Hildenbrand, Alex Bennée

From: Richard Henderson <richard.henderson@linaro.org>

Previously this was only supported for roundAndPackFloat64.

New support in round_canonical, round_to_int, float128_round_to_int,
roundAndPackFloat32, roundAndPackInt32, roundAndPackInt64,
roundAndPackUint64.  This does not include any of the floatx80 routines,
as we do not have users for that rounding mode there.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20190215170225.15537-1-richard.henderson@linaro.org>
Tested-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 fpu/softfloat.c    | 64 ++++++++++++++++++++++++++++++++++++++++++----
 tests/fp/fp-test.c | 43 ++++++++++++++++++++++++-------
 2 files changed, 93 insertions(+), 14 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c69cd6b5d1..99c7cc2c3d 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -696,6 +696,7 @@ static FloatParts sf_canonicalize(FloatParts part, const FloatFmt *parm,
 static FloatParts round_canonical(FloatParts p, float_status *s,
                                   const FloatFmt *parm)
 {
+    const uint64_t frac_lsb = parm->frac_lsb;
     const uint64_t frac_lsbm1 = parm->frac_lsbm1;
     const uint64_t round_mask = parm->round_mask;
     const uint64_t roundeven_mask = parm->roundeven_mask;
@@ -731,6 +732,10 @@ static FloatParts round_canonical(FloatParts p, float_status *s,
             inc = p.sign ? round_mask : 0;
             overflow_norm = !p.sign;
             break;
+        case float_round_to_odd:
+            overflow_norm = true;
+            inc = frac & frac_lsb ? 0 : round_mask;
+            break;
         default:
             g_assert_not_reached();
         }
@@ -778,9 +783,14 @@ static FloatParts round_canonical(FloatParts p, float_status *s,
             shift64RightJamming(frac, 1 - exp, &frac);
             if (frac & round_mask) {
                 /* Need to recompute round-to-even.  */
-                if (s->float_rounding_mode == float_round_nearest_even) {
+                switch (s->float_rounding_mode) {
+                case float_round_nearest_even:
                     inc = ((frac & roundeven_mask) != frac_lsbm1
                            ? frac_lsbm1 : 0);
+                    break;
+                case float_round_to_odd:
+                    inc = frac & frac_lsb ? 0 : round_mask;
+                    break;
                 }
                 flags |= float_flag_inexact;
                 frac += inc;
@@ -1988,6 +1998,9 @@ static FloatParts round_to_int(FloatParts a, int rmode,
             case float_round_down:
                 one = a.sign;
                 break;
+            case float_round_to_odd:
+                one = true;
+                break;
             default:
                 g_assert_not_reached();
             }
@@ -2021,6 +2034,9 @@ static FloatParts round_to_int(FloatParts a, int rmode,
             case float_round_down:
                 inc = a.sign ? rnd_mask : 0;
                 break;
+            case float_round_to_odd:
+                inc = a.frac & frac_lsb ? 0 : rnd_mask;
+                break;
             default:
                 g_assert_not_reached();
             }
@@ -3314,6 +3330,9 @@ static int32_t roundAndPackInt32(flag zSign, uint64_t absZ, float_status *status
     case float_round_down:
         roundIncrement = zSign ? 0x7f : 0;
         break;
+    case float_round_to_odd:
+        roundIncrement = absZ & 0x80 ? 0 : 0x7f;
+        break;
     default:
         abort();
     }
@@ -3368,6 +3387,9 @@ static int64_t roundAndPackInt64(flag zSign, uint64_t absZ0, uint64_t absZ1,
     case float_round_down:
         increment = zSign && absZ1;
         break;
+    case float_round_to_odd:
+        increment = !(absZ0 & 1) && absZ1;
+        break;
     default:
         abort();
     }
@@ -3424,6 +3446,9 @@ static int64_t roundAndPackUint64(flag zSign, uint64_t absZ0,
     case float_round_down:
         increment = zSign && absZ1;
         break;
+    case float_round_to_odd:
+        increment = !(absZ0 & 1) && absZ1;
+        break;
     default:
         abort();
     }
@@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
     case float_round_down:
         roundIncrement = zSign ? 0x7f : 0;
         break;
+    case float_round_to_odd:
+        roundIncrement = zSig & 0x80 ? 0 : 0x7f;
     default:
         abort();
         break;
@@ -3536,8 +3563,10 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
              || (    ( zExp == 0xFD )
                   && ( (int32_t) ( zSig + roundIncrement ) < 0 ) )
            ) {
+            bool overflow_to_inf = roundingMode != float_round_to_odd &&
+                                   roundIncrement != 0;
             float_raise(float_flag_overflow | float_flag_inexact, status);
-            return packFloat32( zSign, 0xFF, - ( roundIncrement == 0 ));
+            return packFloat32(zSign, 0xFF, -!overflow_to_inf);
         }
         if ( zExp < 0 ) {
             if (status->flush_to_zero) {
@@ -3555,6 +3584,13 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
             if (isTiny && roundBits) {
                 float_raise(float_flag_underflow, status);
             }
+            if (roundingMode == float_round_to_odd) {
+                /*
+                 * For round-to-odd case, the roundIncrement depends on
+                 * zSig which just changed.
+                 */
+                roundIncrement = zSig & 0x80 ? 0 : 0x7f;
+            }
         }
     }
     if (roundBits) {
@@ -6987,6 +7023,15 @@ float128 float128_round_to_int(float128 a, float_status *status)
                 add128(z.high, z.low, 0, roundBitsMask, &z.high, &z.low);
             }
             break;
+        case float_round_to_odd:
+            /*
+             * Note that if lastBitMask == 0, the last bit is the lsb
+             * of high, and roundBitsMask == -1.
+             */
+            if ((lastBitMask ? z.low & lastBitMask : z.high & 1) == 0) {
+                add128(z.high, z.low, 0, roundBitsMask, &z.high, &z.low);
+            }
+            break;
         default:
             abort();
         }
@@ -6998,7 +7043,7 @@ float128 float128_round_to_int(float128 a, float_status *status)
             status->float_exception_flags |= float_flag_inexact;
             aSign = extractFloat128Sign( a );
             switch (status->float_rounding_mode) {
-             case float_round_nearest_even:
+            case float_round_nearest_even:
                 if (    ( aExp == 0x3FFE )
                      && (   extractFloat128Frac0( a )
                           | extractFloat128Frac1( a ) )
@@ -7011,14 +7056,17 @@ float128 float128_round_to_int(float128 a, float_status *status)
                     return packFloat128(aSign, 0x3FFF, 0, 0);
                 }
                 break;
-             case float_round_down:
+            case float_round_down:
                 return
                       aSign ? packFloat128( 1, 0x3FFF, 0, 0 )
                     : packFloat128( 0, 0, 0, 0 );
-             case float_round_up:
+            case float_round_up:
                 return
                       aSign ? packFloat128( 1, 0, 0, 0 )
                     : packFloat128( 0, 0x3FFF, 0, 0 );
+
+            case float_round_to_odd:
+                return packFloat128(aSign, 0x3FFF, 0, 0);
             }
             return packFloat128( aSign, 0, 0, 0 );
         }
@@ -7051,6 +7099,12 @@ float128 float128_round_to_int(float128 a, float_status *status)
                 z.high += roundBitsMask;
             }
             break;
+        case float_round_to_odd:
+            if ((z.high & lastBitMask) == 0) {
+                z.high |= (a.low != 0);
+                z.high += roundBitsMask;
+            }
+            break;
         default:
             abort();
         }
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 4114f346a9..7d0faf2b47 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -125,17 +125,42 @@ static void not_implemented(void)
 
 static bool blacklisted(unsigned op, int rmode)
 {
-    /* odd has only been implemented for a few 128-bit ops */
+    /* odd has not been implemented for any 80-bit ops */
     if (rmode == softfloat_round_odd) {
         switch (op) {
-        case F128_ADD:
-        case F128_SUB:
-        case F128_MUL:
-        case F128_DIV:
-        case F128_TO_F64:
-        case F128_SQRT:
-            return false;
-        default:
+        case EXTF80_TO_UI32:
+        case EXTF80_TO_UI64:
+        case EXTF80_TO_I32:
+        case EXTF80_TO_I64:
+        case EXTF80_TO_UI32_R_MINMAG:
+        case EXTF80_TO_UI64_R_MINMAG:
+        case EXTF80_TO_I32_R_MINMAG:
+        case EXTF80_TO_I64_R_MINMAG:
+        case EXTF80_TO_F16:
+        case EXTF80_TO_F32:
+        case EXTF80_TO_F64:
+        case EXTF80_TO_F128:
+        case EXTF80_ROUNDTOINT:
+        case EXTF80_ADD:
+        case EXTF80_SUB:
+        case EXTF80_MUL:
+        case EXTF80_DIV:
+        case EXTF80_REM:
+        case EXTF80_SQRT:
+        case EXTF80_EQ:
+        case EXTF80_LE:
+        case EXTF80_LT:
+        case EXTF80_EQ_SIGNALING:
+        case EXTF80_LE_QUIET:
+        case EXTF80_LT_QUIET:
+        case UI32_TO_EXTF80:
+        case UI64_TO_EXTF80:
+        case I32_TO_EXTF80:
+        case I64_TO_EXTF80:
+        case F16_TO_EXTF80:
+        case F32_TO_EXTF80:
+        case F64_TO_EXTF80:
+        case F128_TO_EXTF80:
             return true;
         }
     }
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32 Alex Bennée
@ 2019-02-22 21:40   ` Richard Henderson
  2019-02-23 10:13     ` Alex Bennée
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2019-02-22 21:40 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: qemu-s390x

On 2/22/19 12:44 PM, Alex Bennée wrote:
> Needed to test: softfloat: add float128_is_{normal,denormal}

Eh?

> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/fp/fp-test.c  | 3 ++-
>  tests/fp/wrap.inc.c | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)

But the rest of the patch matches $SUBJECT, so
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint
  2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint Alex Bennée
@ 2019-02-22 21:40   ` Richard Henderson
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2019-02-22 21:40 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: qemu-s390x

On 2/22/19 12:44 PM, Alex Bennée wrote:
> We've just added f128_to_ui32 and we missed out the f128_to_ui64 tests
> last time.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/Makefile.include | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places
  2019-02-22 20:45 ` [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places Alex Bennée
@ 2019-02-22 21:43   ` Richard Henderson
  2019-02-23 10:11     ` Alex Bennée
  2019-02-23 10:19     ` Alex Bennée
  0 siblings, 2 replies; 13+ messages in thread
From: Richard Henderson @ 2019-02-22 21:43 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: qemu-s390x, David Hildenbrand

On 2/22/19 12:45 PM, Alex Bennée wrote:
> @@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
>      case float_round_down:
>          roundIncrement = zSign ? 0x7f : 0;
>          break;
> +    case float_round_to_odd:
> +        roundIncrement = zSig & 0x80 ? 0 : 0x7f;
>      default:
>          abort();

I clearly missed a break here.

Since this didn't kill fp-test, are we missing a float128_to_float32 test?


r~

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places
  2019-02-22 21:43   ` Richard Henderson
@ 2019-02-23 10:11     ` Alex Bennée
  2019-02-23 10:19     ` Alex Bennée
  1 sibling, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-23 10:11 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, qemu-s390x, David Hildenbrand


Richard Henderson <richard.henderson@linaro.org> writes:

> On 2/22/19 12:45 PM, Alex Bennée wrote:
>> @@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
>>      case float_round_down:
>>          roundIncrement = zSign ? 0x7f : 0;
>>          break;
>> +    case float_round_to_odd:
>> +        roundIncrement = zSig & 0x80 ? 0 : 0x7f;
>>      default:
>>          abort();
>
> I clearly missed a break here.
>
> Since this didn't kill fp-test, are we missing a float128_to_float32
> test?

Ahh yes missing that:

10:11:17 [alex@zen:~/l/q/b/a/t/fp] fpu/next + ./fp-test f16_to_f32 f64_to_f32 f128_to_f32 -r odd
>> Testing f16_to_f32
408 tests total.
408 tests performed.
In 408 tests, no errors found in f16_to_f32.
>> Testing f64_to_f32, rounding odd, tininess before rounding
768 tests total.
768 tests performed.
In 768 tests, no errors found in f64_to_f32, rounding odd, tininess before rounding.
>> Testing f64_to_f32, rounding odd, tininess after rounding
768 tests total.
768 tests performed.
In 768 tests, no errors found in f64_to_f32, rounding odd, tininess after rounding.
>> Testing f128_to_f32, rounding odd, tininess before rounding
936 tests total.
fish: “./fp-test f16_to_f32 f64_to_f32…” terminated by signal SIGABRT (Abort)

I'll patch it up and fix.

>
>
> r~


--
Alex Bennée

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32
  2019-02-22 21:40   ` Richard Henderson
@ 2019-02-23 10:13     ` Alex Bennée
  0 siblings, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-23 10:13 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, qemu-s390x


Richard Henderson <richard.henderson@linaro.org> writes:

> On 2/22/19 12:44 PM, Alex Bennée wrote:
>> Needed to test: softfloat: add float128_is_{normal,denormal}

Obviously I was reading the title of the other patch.. will fix.

>
> Eh?
>
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>  tests/fp/fp-test.c  | 3 ++-
>>  tests/fp/wrap.inc.c | 1 +
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>
> But the rest of the patch matches $SUBJECT, so
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
>
> r~


--
Alex Bennée

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places
  2019-02-22 21:43   ` Richard Henderson
  2019-02-23 10:11     ` Alex Bennée
@ 2019-02-23 10:19     ` Alex Bennée
  1 sibling, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2019-02-23 10:19 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, qemu-s390x, David Hildenbrand


Richard Henderson <richard.henderson@linaro.org> writes:

> On 2/22/19 12:45 PM, Alex Bennée wrote:
>> @@ -3526,6 +3551,8 @@ static float32 roundAndPackFloat32(flag zSign, int zExp, uint32_t zSig,
>>      case float_round_down:
>>          roundIncrement = zSign ? 0x7f : 0;
>>          break;
>> +    case float_round_to_odd:
>> +        roundIncrement = zSig & 0x80 ? 0 : 0x7f;
>>      default:
>>          abort();
>
> I clearly missed a break here.
>
> Since this didn't kill fp-test, are we missing a float128_to_float32
> test?

So I've not got -r all against all tests but adding it to make mulAdd
take even longer to run so maybe I'll not bother for mulAdd.

>
>
> r~


--
Alex Bennée

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-02-23 10:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 20:44 [Qemu-devel] [PATCH v1 0/6] fpu/next, mostly bits s390x tcg will need Alex Bennée
2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 1/6] tests: Ignore fp test outputs Alex Bennée
2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 2/6] softfloat: add float128_is_{normal, denormal} Alex Bennée
2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 3/6] softfloat: Implement float128_to_uint32 Alex Bennée
2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 4/6] tests/fp: add wrapping for f128_to_ui32 Alex Bennée
2019-02-22 21:40   ` Richard Henderson
2019-02-23 10:13     ` Alex Bennée
2019-02-22 20:44 ` [Qemu-devel] [PATCH v1 5/6] tests/fp: enable f128_to_ui[32/64] tests in float-to-uint Alex Bennée
2019-02-22 21:40   ` Richard Henderson
2019-02-22 20:45 ` [Qemu-devel] [PATCH v1 6/6] softfloat: Support float_round_to_odd more places Alex Bennée
2019-02-22 21:43   ` Richard Henderson
2019-02-23 10:11     ` Alex Bennée
2019-02-23 10:19     ` Alex Bennée

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.