All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo
@ 2023-05-27 14:19 Richard Henderson
  2023-05-27 14:19 ` [PATCH 1/4] " Richard Henderson
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Richard Henderson @ 2023-05-27 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

Extract some common code from Alpha and Arm, and which will
shortly also be required by the RISC-V Zfa extension.
Added a new test for Alpha; I already had a RISU test for Arm.


r~


Richard Henderson (4):
  fpu: Add float64_to_int{32,64}_modulo
  tests/tcg/alpha: Add test for cvttq
  target/alpha: Use float64_to_int64_modulo for CVTTQ
  target/arm: Use float64_to_int32_modulo for FJCVTZS

 include/fpu/softfloat.h         |  3 ++
 fpu/softfloat.c                 | 31 ++++++++++++
 target/alpha/fpu_helper.c       | 85 +++++++--------------------------
 target/arm/vfp_helper.c         | 71 +++++----------------------
 tests/tcg/alpha/test-cvttq.c    | 78 ++++++++++++++++++++++++++++++
 fpu/softfloat-parts.c.inc       | 78 ++++++++++++++++++++++++++++++
 tests/tcg/alpha/Makefile.target |  2 +-
 7 files changed, 221 insertions(+), 127 deletions(-)
 create mode 100644 tests/tcg/alpha/test-cvttq.c

-- 
2.34.1



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

* [PATCH 1/4] fpu: Add float64_to_int{32,64}_modulo
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
@ 2023-05-27 14:19 ` Richard Henderson
  2023-06-27 10:03   ` Alex Bennée
  2023-05-27 14:19 ` [PATCH 2/4] tests/tcg/alpha: Add test for cvttq Richard Henderson
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2023-05-27 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

Add versions of float64_to_int* which do not saturate the result.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/fpu/softfloat.h   |  3 ++
 fpu/softfloat.c           | 31 ++++++++++++++++
 fpu/softfloat-parts.c.inc | 78 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 3dcf20e3a2..cd130564d8 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -751,6 +751,9 @@ int16_t float64_to_int16_round_to_zero(float64, float_status *status);
 int32_t float64_to_int32_round_to_zero(float64, float_status *status);
 int64_t float64_to_int64_round_to_zero(float64, float_status *status);
 
+int32_t float64_to_int32_modulo(float64, FloatRoundMode, float_status *status);
+int64_t float64_to_int64_modulo(float64, FloatRoundMode, float_status *status);
+
 uint16_t float64_to_uint16_scalbn(float64, FloatRoundMode, int, float_status *);
 uint32_t float64_to_uint32_scalbn(float64, FloatRoundMode, int, float_status *);
 uint64_t float64_to_uint64_scalbn(float64, FloatRoundMode, int, float_status *);
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 108f9cb224..c05819afcd 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -852,11 +852,24 @@ static uint64_t parts128_float_to_uint(FloatParts128 *p, FloatRoundMode rmode,
 #define parts_float_to_uint(P, R, Z, M, S) \
     PARTS_GENERIC_64_128(float_to_uint, P)(P, R, Z, M, S)
 
+static int64_t parts64_float_to_sint_modulo(FloatParts64 *p,
+                                            FloatRoundMode rmode,
+                                            int bitsm1, float_status *s);
+static int64_t parts128_float_to_sint_modulo(FloatParts128 *p,
+                                             FloatRoundMode rmode,
+                                             int bitsm1, float_status *s);
+
+#define parts_float_to_sint_modulo(P, R, M, S) \
+    PARTS_GENERIC_64_128(float_to_sint_modulo, P)(P, R, M, S)
+
 static void parts64_sint_to_float(FloatParts64 *p, int64_t a,
                                   int scale, float_status *s);
 static void parts128_sint_to_float(FloatParts128 *p, int64_t a,
                                    int scale, float_status *s);
 
+#define parts_float_to_sint(P, R, Z, MN, MX, S) \
+    PARTS_GENERIC_64_128(float_to_sint, P)(P, R, Z, MN, MX, S)
+
 #define parts_sint_to_float(P, I, Z, S) \
     PARTS_GENERIC_64_128(sint_to_float, P)(P, I, Z, S)
 
@@ -3409,6 +3422,24 @@ int64_t bfloat16_to_int64_round_to_zero(bfloat16 a, float_status *s)
     return bfloat16_to_int64_scalbn(a, float_round_to_zero, 0, s);
 }
 
+int32_t float64_to_int32_modulo(float64 a, FloatRoundMode rmode,
+                                float_status *s)
+{
+    FloatParts64 p;
+
+    float64_unpack_canonical(&p, a, s);
+    return parts_float_to_sint_modulo(&p, rmode, 31, s);
+}
+
+int64_t float64_to_int64_modulo(float64 a, FloatRoundMode rmode,
+                                float_status *s)
+{
+    FloatParts64 p;
+
+    float64_unpack_canonical(&p, a, s);
+    return parts_float_to_sint_modulo(&p, rmode, 63, s);
+}
+
 /*
  * Floating-point to unsigned integer conversions
  */
diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc
index 247400031c..527e15e6ab 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -1181,6 +1181,84 @@ static uint64_t partsN(float_to_uint)(FloatPartsN *p, FloatRoundMode rmode,
     return r;
 }
 
+/*
+ * Like partsN(float_to_sint), except do not saturate the result.
+ * Instead, return the rounded unbounded precision two's compliment result,
+ * modulo 2**(bitsm1 + 1).
+ */
+static int64_t partsN(float_to_sint_modulo)(FloatPartsN *p,
+                                            FloatRoundMode rmode,
+                                            int bitsm1, float_status *s)
+{
+    int flags = 0;
+    uint64_t r;
+    bool overflow = false;
+
+    switch (p->cls) {
+    case float_class_snan:
+        flags |= float_flag_invalid_snan;
+        /* fall through */
+    case float_class_qnan:
+        flags |= float_flag_invalid;
+        r = 0;
+        break;
+
+    case float_class_inf:
+        overflow = true;
+        r = 0;
+        break;
+
+    case float_class_zero:
+        return 0;
+
+    case float_class_normal:
+        /* TODO: N - 2 is frac_size for rounding; could use input fmt. */
+        if (parts_round_to_int_normal(p, rmode, 0, N - 2)) {
+            flags = float_flag_inexact;
+        }
+
+        if (p->exp <= DECOMPOSED_BINARY_POINT) {
+            /*
+             * Because we rounded to integral, and exp < 64,
+             * we know frac_low is zero.
+             */
+            r = p->frac_hi >> (DECOMPOSED_BINARY_POINT - p->exp);
+            if (p->exp < bitsm1) {
+                /* Result in range. */
+            } else if (p->exp == bitsm1) {
+                /* The only in-range value is INT_MIN. */
+                overflow = !p->sign || p->frac_hi != DECOMPOSED_IMPLICIT_BIT;
+            } else {
+                overflow = true;
+            }
+        } else {
+            /* Overflow, but there might still be bits to return. */
+            int shl = p->exp - DECOMPOSED_BINARY_POINT;
+            if (shl < N) {
+                frac_shl(p, shl);
+                r = p->frac_hi;
+            } else {
+                r = 0;
+            }
+            overflow = true;
+        }
+
+        if (p->sign) {
+            r = -r;
+        }
+        break;
+
+    default:
+        g_assert_not_reached();
+    }
+
+    if (overflow) {
+        flags = float_flag_invalid | float_flag_invalid_cvti;
+    }
+    float_raise(flags, s);
+    return r;
+}
+
 /*
  * Integer to float conversions
  *
-- 
2.34.1



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

* [PATCH 2/4] tests/tcg/alpha: Add test for cvttq
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
  2023-05-27 14:19 ` [PATCH 1/4] " Richard Henderson
@ 2023-05-27 14:19 ` Richard Henderson
  2023-06-23 15:48   ` Alex Bennée
  2023-06-27 10:08   ` Alex Bennée
  2023-05-27 14:19 ` [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ Richard Henderson
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Richard Henderson @ 2023-05-27 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

Test for invalid, integer overflow, and inexact.
Test for proper result, modulo 2**64.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 tests/tcg/alpha/test-cvttq.c    | 78 +++++++++++++++++++++++++++++++++
 tests/tcg/alpha/Makefile.target |  2 +-
 2 files changed, 79 insertions(+), 1 deletion(-)
 create mode 100644 tests/tcg/alpha/test-cvttq.c

diff --git a/tests/tcg/alpha/test-cvttq.c b/tests/tcg/alpha/test-cvttq.c
new file mode 100644
index 0000000000..d1ad995312
--- /dev/null
+++ b/tests/tcg/alpha/test-cvttq.c
@@ -0,0 +1,78 @@
+#include <stdio.h>
+
+#define FPCR_SUM                (1UL << 63)
+#define FPCR_INED               (1UL << 62)
+#define FPCR_UNFD               (1UL << 61)
+#define FPCR_UNDZ               (1UL << 60)
+#define FPCR_DYN_SHIFT          58
+#define FPCR_DYN_CHOPPED        (0UL << FPCR_DYN_SHIFT)
+#define FPCR_DYN_MINUS          (1UL << FPCR_DYN_SHIFT)
+#define FPCR_DYN_NORMAL         (2UL << FPCR_DYN_SHIFT)
+#define FPCR_DYN_PLUS           (3UL << FPCR_DYN_SHIFT)
+#define FPCR_DYN_MASK           (3UL << FPCR_DYN_SHIFT)
+#define FPCR_IOV                (1UL << 57)
+#define FPCR_INE                (1UL << 56)
+#define FPCR_UNF                (1UL << 55)
+#define FPCR_OVF                (1UL << 54)
+#define FPCR_DZE                (1UL << 53)
+#define FPCR_INV                (1UL << 52)
+#define FPCR_OVFD               (1UL << 51)
+#define FPCR_DZED               (1UL << 50)
+#define FPCR_INVD               (1UL << 49)
+#define FPCR_DNZ                (1UL << 48)
+#define FPCR_DNOD               (1UL << 47)
+#define FPCR_STATUS_MASK        (FPCR_IOV | FPCR_INE | FPCR_UNF \
+                                 | FPCR_OVF | FPCR_DZE | FPCR_INV)
+
+static long test_cvttq(long *ret_e, double d)
+{
+    unsigned long reset = (FPCR_INED | FPCR_UNFD | FPCR_OVFD | FPCR_DZED |
+                           FPCR_INVD | FPCR_DYN_NORMAL);
+    long r, e;
+
+    asm("excb\n\t"
+        "mt_fpcr %3\n\t"
+        "excb\n\t"
+        "cvttq/svic %2, %0\n\t"
+        "excb\n\t"
+        "mf_fpcr %1\n\t"
+        "excb\n\t"
+        : "=f"(r), "=f"(e)
+        : "f"(d), "f"(reset));
+
+    *ret_e = e & FPCR_STATUS_MASK;
+    return r;
+}
+
+int main (void)
+{
+    static const struct {
+        double d;
+        long r;
+        long e;
+    } T[] = {
+        {  1.0,  1, 0 },
+        { -1.0, -1, 0 },
+        {  1.5,  1, FPCR_INE },
+        {  0x1.0p32,   0x0000000100000000ul, 0 },
+        { -0x1.0p63,   0x8000000000000000ul, 0 },
+        {  0x1.0p63,   0x8000000000000000ul, FPCR_IOV | FPCR_INE },
+        {  0x1.0p64,   0x0000000000000000ul, FPCR_IOV | FPCR_INE },
+        {  0x1.cccp64, 0xccc0000000000000ul, FPCR_IOV | FPCR_INE },
+        { __builtin_inf(), 0, FPCR_INV },
+        { __builtin_nan(""), 0, FPCR_INV },
+    };
+
+    int i, err = 0;
+
+    for (i = 0; i < sizeof(T)/sizeof(T[0]); i++) {
+        long e, r = test_cvttq(&e, T[i].d);
+
+        if (r != T[i].r || e != T[i].e) {
+            printf("Fail %a: expect (%016lx : %04lx) got (%016lx : %04lx)\n",
+                   T[i].d, T[i].r, T[i].e >> 48, r, e >> 48);
+            err = 1;
+        }
+    }
+    return err;
+}
diff --git a/tests/tcg/alpha/Makefile.target b/tests/tcg/alpha/Makefile.target
index a585080328..b94500a7d9 100644
--- a/tests/tcg/alpha/Makefile.target
+++ b/tests/tcg/alpha/Makefile.target
@@ -5,7 +5,7 @@
 ALPHA_SRC=$(SRC_PATH)/tests/tcg/alpha
 VPATH+=$(ALPHA_SRC)
 
-ALPHA_TESTS=hello-alpha test-cond test-cmov test-ovf
+ALPHA_TESTS=hello-alpha test-cond test-cmov test-ovf test-cvttq
 TESTS+=$(ALPHA_TESTS)
 
 test-cmov: EXTRA_CFLAGS=-DTEST_CMOV
-- 
2.34.1



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

* [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
  2023-05-27 14:19 ` [PATCH 1/4] " Richard Henderson
  2023-05-27 14:19 ` [PATCH 2/4] tests/tcg/alpha: Add test for cvttq Richard Henderson
@ 2023-05-27 14:19 ` Richard Henderson
  2023-06-27  9:27   ` Philippe Mathieu-Daudé
  2023-05-27 14:19 ` [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS Richard Henderson
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2023-05-27 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

For the most part we can use the new generic routine,
though exceptions need some post-processing to sort
invalid from integer overflow.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/alpha/fpu_helper.c | 85 +++++++++------------------------------
 1 file changed, 18 insertions(+), 67 deletions(-)

diff --git a/target/alpha/fpu_helper.c b/target/alpha/fpu_helper.c
index 3ff8bb456d..63d9e9ce39 100644
--- a/target/alpha/fpu_helper.c
+++ b/target/alpha/fpu_helper.c
@@ -453,78 +453,29 @@ uint64_t helper_cvtqs(CPUAlphaState *env, uint64_t a)
 
 static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode)
 {
-    uint64_t frac, ret = 0;
-    uint32_t exp, sign, exc = 0;
-    int shift;
+    float64 fa;
+    int64_t ret;
+    uint32_t exc;
 
-    sign = (a >> 63);
-    exp = (uint32_t)(a >> 52) & 0x7ff;
-    frac = a & 0xfffffffffffffull;
+    fa = t_to_float64(a);
+    ret = float64_to_int64_modulo(fa, roundmode, &FP_STATUS);
 
-    if (exp == 0) {
-        if (unlikely(frac != 0) && !env->fp_status.flush_inputs_to_zero) {
-            goto do_underflow;
-        }
-    } else if (exp == 0x7ff) {
-        exc = FPCR_INV;
-    } else {
-        /* Restore implicit bit.  */
-        frac |= 0x10000000000000ull;
+    exc = get_float_exception_flags(&FP_STATUS);
+    if (unlikely(exc)) {
+        set_float_exception_flags(0, &FP_STATUS);
 
-        shift = exp - 1023 - 52;
-        if (shift >= 0) {
-            /* In this case the number is so large that we must shift
-               the fraction left.  There is no rounding to do.  */
-            if (shift < 64) {
-                ret = frac << shift;
-            }
-            /* Check for overflow.  Note the special case of -0x1p63.  */
-            if (shift >= 11 && a != 0xC3E0000000000000ull) {
+        /* We need to massage the resulting exceptions. */
+        if (exc & float_flag_invalid_cvti) {
+            /* Overflow, either normal or infinity. */
+            if (float64_is_infinity(fa)) {
+                exc = FPCR_INV;
+            } else {
                 exc = FPCR_IOV | FPCR_INE;
             }
-        } else {
-            uint64_t round;
-
-            /* In this case the number is smaller than the fraction as
-               represented by the 52 bit number.  Here we must think
-               about rounding the result.  Handle this by shifting the
-               fractional part of the number into the high bits of ROUND.
-               This will let us efficiently handle round-to-nearest.  */
-            shift = -shift;
-            if (shift < 63) {
-                ret = frac >> shift;
-                round = frac << (64 - shift);
-            } else {
-                /* The exponent is so small we shift out everything.
-                   Leave a sticky bit for proper rounding below.  */
-            do_underflow:
-                round = 1;
-            }
-
-            if (round) {
-                exc = FPCR_INE;
-                switch (roundmode) {
-                case float_round_nearest_even:
-                    if (round == (1ull << 63)) {
-                        /* Fraction is exactly 0.5; round to even.  */
-                        ret += (ret & 1);
-                    } else if (round > (1ull << 63)) {
-                        ret += 1;
-                    }
-                    break;
-                case float_round_to_zero:
-                    break;
-                case float_round_up:
-                    ret += 1 - sign;
-                    break;
-                case float_round_down:
-                    ret += sign;
-                    break;
-                }
-            }
-        }
-        if (sign) {
-            ret = -ret;
+        } else if (exc & float_flag_invalid) {
+            exc = FPCR_INV;
+        } else if (exc & float_flag_inexact) {
+            exc = FPCR_INE;
         }
     }
     env->error_code = exc;
-- 
2.34.1



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

* [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
                   ` (2 preceding siblings ...)
  2023-05-27 14:19 ` [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ Richard Henderson
@ 2023-05-27 14:19 ` Richard Henderson
  2023-06-27 10:32   ` Alex Bennée
  2023-06-21  9:12 ` [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2023-05-27 14:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

The standard floating point results are provided by the generic routine.
We only need handle the extra Z flag result afterward.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/vfp_helper.c | 71 +++++++----------------------------------
 1 file changed, 12 insertions(+), 59 deletions(-)

diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 36906db8e0..789bba36cc 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -1120,68 +1120,21 @@ const FloatRoundMode arm_rmode_to_sf_map[] = {
 uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus)
 {
     float_status *status = vstatus;
-    uint32_t exp, sign;
-    uint64_t frac;
-    uint32_t inexact = 1; /* !Z */
+    uint32_t inexact, frac;
+    uint32_t e_old, e_new;
 
-    sign = extract64(value, 63, 1);
-    exp = extract64(value, 52, 11);
-    frac = extract64(value, 0, 52);
+    e_old = get_float_exception_flags(status);
+    set_float_exception_flags(0, status);
+    frac = float64_to_int32_modulo(value, float_round_to_zero, status);
+    e_new = get_float_exception_flags(status);
+    set_float_exception_flags(e_old | e_new, status);
 
-    if (exp == 0) {
-        /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript.  */
-        inexact = sign;
-        if (frac != 0) {
-            if (status->flush_inputs_to_zero) {
-                float_raise(float_flag_input_denormal, status);
-            } else {
-                float_raise(float_flag_inexact, status);
-                inexact = 1;
-            }
-        }
-        frac = 0;
-    } else if (exp == 0x7ff) {
-        /* This operation raises Invalid for both NaN and overflow (Inf).  */
-        float_raise(float_flag_invalid, status);
-        frac = 0;
+    if (value == float64_chs(float64_zero)) {
+        /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */
+        inexact = 1;
     } else {
-        int true_exp = exp - 1023;
-        int shift = true_exp - 52;
-
-        /* Restore implicit bit.  */
-        frac |= 1ull << 52;
-
-        /* Shift the fraction into place.  */
-        if (shift >= 0) {
-            /* The number is so large we must shift the fraction left.  */
-            if (shift >= 64) {
-                /* The fraction is shifted out entirely.  */
-                frac = 0;
-            } else {
-                frac <<= shift;
-            }
-        } else if (shift > -64) {
-            /* Normal case -- shift right and notice if bits shift out.  */
-            inexact = (frac << (64 + shift)) != 0;
-            frac >>= -shift;
-        } else {
-            /* The fraction is shifted out entirely.  */
-            frac = 0;
-        }
-
-        /* Notice overflow or inexact exceptions.  */
-        if (true_exp > 31 || frac > (sign ? 0x80000000ull : 0x7fffffff)) {
-            /* Overflow, for which this operation raises invalid.  */
-            float_raise(float_flag_invalid, status);
-            inexact = 1;
-        } else if (inexact) {
-            float_raise(float_flag_inexact, status);
-        }
-
-        /* Honor the sign.  */
-        if (sign) {
-            frac = -frac;
-        }
+        /* Normal inexact or overflow or NaN */
+        inexact = e_new & (float_flag_inexact | float_flag_invalid);
     }
 
     /* Pack the result and the env->ZF representation of Z together.  */
-- 
2.34.1



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

* Re: [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
                   ` (3 preceding siblings ...)
  2023-05-27 14:19 ` [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS Richard Henderson
@ 2023-06-21  9:12 ` Richard Henderson
  2023-06-27  7:12   ` Richard Henderson
  2023-06-30  8:03 ` Christoph Müllner
  2023-06-30 13:36 ` Richard Henderson
  6 siblings, 1 reply; 14+ messages in thread
From: Richard Henderson @ 2023-06-21  9:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

On 5/27/23 16:19, Richard Henderson wrote:
> Extract some common code from Alpha and Arm, and which will
> shortly also be required by the RISC-V Zfa extension.
> Added a new test for Alpha; I already had a RISU test for Arm.
> 
> 
> r~
> 
> 
> Richard Henderson (4):
>    fpu: Add float64_to_int{32,64}_modulo
>    tests/tcg/alpha: Add test for cvttq
>    target/alpha: Use float64_to_int64_modulo for CVTTQ
>    target/arm: Use float64_to_int32_modulo for FJCVTZS
> 
>   include/fpu/softfloat.h         |  3 ++
>   fpu/softfloat.c                 | 31 ++++++++++++
>   target/alpha/fpu_helper.c       | 85 +++++++--------------------------
>   target/arm/vfp_helper.c         | 71 +++++----------------------
>   tests/tcg/alpha/test-cvttq.c    | 78 ++++++++++++++++++++++++++++++
>   fpu/softfloat-parts.c.inc       | 78 ++++++++++++++++++++++++++++++
>   tests/tcg/alpha/Makefile.target |  2 +-
>   7 files changed, 221 insertions(+), 127 deletions(-)
>   create mode 100644 tests/tcg/alpha/test-cvttq.c
> 
ping.

r~


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

* Re: [PATCH 2/4] tests/tcg/alpha: Add test for cvttq
  2023-05-27 14:19 ` [PATCH 2/4] tests/tcg/alpha: Add test for cvttq Richard Henderson
@ 2023-06-23 15:48   ` Alex Bennée
  2023-06-27 10:08   ` Alex Bennée
  1 sibling, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2023-06-23 15:48 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, christoph.muellner


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

> Test for invalid, integer overflow, and inexact.
> Test for proper result, modulo 2**64.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Acked-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo
  2023-06-21  9:12 ` [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
@ 2023-06-27  7:12   ` Richard Henderson
  0 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2023-06-27  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

On 6/21/23 11:12, Richard Henderson wrote:
> On 5/27/23 16:19, Richard Henderson wrote:
>> Extract some common code from Alpha and Arm, and which will
>> shortly also be required by the RISC-V Zfa extension.
>> Added a new test for Alpha; I already had a RISU test for Arm.
>>
>>
>> r~
>>
>>
>> Richard Henderson (4):
>>    fpu: Add float64_to_int{32,64}_modulo
>>    tests/tcg/alpha: Add test for cvttq
>>    target/alpha: Use float64_to_int64_modulo for CVTTQ
>>    target/arm: Use float64_to_int32_modulo for FJCVTZS
>>
>>   include/fpu/softfloat.h         |  3 ++
>>   fpu/softfloat.c                 | 31 ++++++++++++
>>   target/alpha/fpu_helper.c       | 85 +++++++--------------------------
>>   target/arm/vfp_helper.c         | 71 +++++----------------------
>>   tests/tcg/alpha/test-cvttq.c    | 78 ++++++++++++++++++++++++++++++
>>   fpu/softfloat-parts.c.inc       | 78 ++++++++++++++++++++++++++++++
>>   tests/tcg/alpha/Makefile.target |  2 +-
>>   7 files changed, 221 insertions(+), 127 deletions(-)
>>   create mode 100644 tests/tcg/alpha/test-cvttq.c
>>
> ping.

ping 2.

r~



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

* Re: [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ
  2023-05-27 14:19 ` [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ Richard Henderson
@ 2023-06-27  9:27   ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 14+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-27  9:27 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: christoph.muellner, alex.bennee

On 27/5/23 16:19, Richard Henderson wrote:
> For the most part we can use the new generic routine,
> though exceptions need some post-processing to sort
> invalid from integer overflow.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   target/alpha/fpu_helper.c | 85 +++++++++------------------------------
>   1 file changed, 18 insertions(+), 67 deletions(-)

To the best of my knowledge...
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

* Re: [PATCH 1/4] fpu: Add float64_to_int{32,64}_modulo
  2023-05-27 14:19 ` [PATCH 1/4] " Richard Henderson
@ 2023-06-27 10:03   ` Alex Bennée
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2023-06-27 10:03 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, christoph.muellner


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

> Add versions of float64_to_int* which do not saturate the result.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH 2/4] tests/tcg/alpha: Add test for cvttq
  2023-05-27 14:19 ` [PATCH 2/4] tests/tcg/alpha: Add test for cvttq Richard Henderson
  2023-06-23 15:48   ` Alex Bennée
@ 2023-06-27 10:08   ` Alex Bennée
  1 sibling, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2023-06-27 10:08 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, christoph.muellner


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

> Test for invalid, integer overflow, and inexact.
> Test for proper result, modulo 2**64.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Acked-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS
  2023-05-27 14:19 ` [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS Richard Henderson
@ 2023-06-27 10:32   ` Alex Bennée
  0 siblings, 0 replies; 14+ messages in thread
From: Alex Bennée @ 2023-06-27 10:32 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, christoph.muellner


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

> The standard floating point results are provided by the generic routine.
> We only need handle the extra Z flag result afterward.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

* Re: [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
                   ` (4 preceding siblings ...)
  2023-06-21  9:12 ` [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
@ 2023-06-30  8:03 ` Christoph Müllner
  2023-06-30 13:36 ` Richard Henderson
  6 siblings, 0 replies; 14+ messages in thread
From: Christoph Müllner @ 2023-06-30  8:03 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, alex.bennee

On Sat, May 27, 2023 at 4:19 PM Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Extract some common code from Alpha and Arm, and which will
> shortly also be required by the RISC-V Zfa extension.
> Added a new test for Alpha; I already had a RISU test for Arm.

Thank you for providing a generic implementation of this conversion!

I've rebased the RISC-V Zfa patch onto this series and could
implement the fcvtmod.w.d instruction (with a little bit of flag manipulation
after calling float64_to_int32()).

Reviewed-by: Christoph Muellner <christoph.muellner@vrull.eu>
Tested-by: Christoph Muellner <christoph.muellner@vrull.eu>

>
>
> r~
>
>
> Richard Henderson (4):
>   fpu: Add float64_to_int{32,64}_modulo
>   tests/tcg/alpha: Add test for cvttq
>   target/alpha: Use float64_to_int64_modulo for CVTTQ
>   target/arm: Use float64_to_int32_modulo for FJCVTZS
>
>  include/fpu/softfloat.h         |  3 ++
>  fpu/softfloat.c                 | 31 ++++++++++++
>  target/alpha/fpu_helper.c       | 85 +++++++--------------------------
>  target/arm/vfp_helper.c         | 71 +++++----------------------
>  tests/tcg/alpha/test-cvttq.c    | 78 ++++++++++++++++++++++++++++++
>  fpu/softfloat-parts.c.inc       | 78 ++++++++++++++++++++++++++++++
>  tests/tcg/alpha/Makefile.target |  2 +-
>  7 files changed, 221 insertions(+), 127 deletions(-)
>  create mode 100644 tests/tcg/alpha/test-cvttq.c
>
> --
> 2.34.1
>


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

* Re: [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo
  2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
                   ` (5 preceding siblings ...)
  2023-06-30  8:03 ` Christoph Müllner
@ 2023-06-30 13:36 ` Richard Henderson
  6 siblings, 0 replies; 14+ messages in thread
From: Richard Henderson @ 2023-06-30 13:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: christoph.muellner, alex.bennee

On 5/27/23 16:19, Richard Henderson wrote:
> Extract some common code from Alpha and Arm, and which will
> shortly also be required by the RISC-V Zfa extension.
> Added a new test for Alpha; I already had a RISU test for Arm.
> 
> 
> r~
> 
> 
> Richard Henderson (4):
>    fpu: Add float64_to_int{32,64}_modulo
>    tests/tcg/alpha: Add test for cvttq
>    target/alpha: Use float64_to_int64_modulo for CVTTQ
>    target/arm: Use float64_to_int32_modulo for FJCVTZS

Queued to tcg-next.


r~



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

end of thread, other threads:[~2023-06-30 13:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-27 14:19 [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
2023-05-27 14:19 ` [PATCH 1/4] " Richard Henderson
2023-06-27 10:03   ` Alex Bennée
2023-05-27 14:19 ` [PATCH 2/4] tests/tcg/alpha: Add test for cvttq Richard Henderson
2023-06-23 15:48   ` Alex Bennée
2023-06-27 10:08   ` Alex Bennée
2023-05-27 14:19 ` [PATCH 3/4] target/alpha: Use float64_to_int64_modulo for CVTTQ Richard Henderson
2023-06-27  9:27   ` Philippe Mathieu-Daudé
2023-05-27 14:19 ` [PATCH 4/4] target/arm: Use float64_to_int32_modulo for FJCVTZS Richard Henderson
2023-06-27 10:32   ` Alex Bennée
2023-06-21  9:12 ` [PATCH 0/4] fpu: Add float64_to_int{32,64}_modulo Richard Henderson
2023-06-27  7:12   ` Richard Henderson
2023-06-30  8:03 ` Christoph Müllner
2023-06-30 13:36 ` Richard Henderson

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.