On 2026-01-29 19:57, Ilya Leoshkevich wrote:
DIVIDE TO INTEGER computes floating point remainder and is used by
LuaJIT, so add it to QEMU.

Put the main logic into fpu/, because it is way more convenient to
operate on FloatParts than to convert floats back-and-forth.

Signed-off-by: Ilya Leoshkevich <[email protected]>
---
 fpu/softfloat.c                  | 144 +++++++++++++++++++++++++++++++
 include/fpu/softfloat.h          |  11 +++
 target/s390x/helper.h            |   1 +
 target/s390x/tcg/fpu_helper.c    |  56 ++++++++++++
 target/s390x/tcg/insn-data.h.inc |   5 +-
 target/s390x/tcg/translate.c     |  26 ++++++
 6 files changed, 242 insertions(+), 1 deletion(-)

I've taken a fresh look and I think I can improve one small thing.
I will change this alongside other feedback (if any) in v4.

[...]

+
+        /*
+ * Final quotient is rounded using final-quotient-rounding method, and
+         * partial quotient is rounded toward zero.
+         *
+ * Rounding of partial quotient may be inexact. This is the whole point + * of distinguishing partial quotients, so ignore the exception.
+         */
+        *n = *q;
+        saved_flags = status->float_exception_flags;
+        parts_round_to_int(n,
+ is_q_smallish ? final_quotient_rounding_mode :
+                                           float_round_to_zero,
+                           0, status, fmt);
+        float_exception_flags = saved_flags;

saved_flags can probably be eliminated; I can assign directly to float_exception_flags. I think I can also use parts_round_to_int_normal(), because all the other cases are taken care of above.

[...]

Reply via email to