All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203
@ 2026-11-30 20:16 Alex Bennée
  2026-11-30 20:16 ` [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts Alex Bennée
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Alex Bennée, Marc-André Lureau,
	Peter Maydell, Philippe Mathieu-Daudé, Xianglai Li,
	qemu-riscv, qemu-arm, Daniel Henrique Barboza, qemu-ppc,
	Brian Cain, Nicholas Piggin, Ilya Leoshkevich, Alistair Francis,
	Helge Deller, Weiwei Li, Richard Henderson, Aurelien Jarno,
	Chao Liu, Pierrick Bouvier, Palmer Dabbelt, Stafford Horne,
	Glenn Miles, Harsh Prateek Bora, Chinmay Rath, Paolo Bonzini,
	Bibo Mao

We had a bug reported that fma fails on some platforms. I can't test
the fix but I took the opportunity to extend the TCG test cases to
cover a few more of the fma corner cases along with what is hopefully
the fix.

Alex.

Alex Bennée (4):
  meson: expose MESON_SOURCE_ROOT to scripts
  scripts/tests: add regen-reference.sh
  tests/tcg: extend the float_madds test case
  fpu/softfloat: gate hardfloat on working fmaf

 meson.build                           |  1 +
 fpu/softfloat.c                       | 10 +++
 tests/tcg/multiarch/float_madds.c     | 13 ++++
 scripts/tests/regen-reference.sh      | 87 +++++++++++++++++++++++++++
 tests/tcg/aarch64/float_madds.ref     | 64 ++++++++++++++++++++
 tests/tcg/alpha/float_madds.ref       | 64 ++++++++++++++++++++
 tests/tcg/arm/float_madds.ref         | 64 ++++++++++++++++++++
 tests/tcg/hexagon/float_madds.ref     | 64 ++++++++++++++++++++
 tests/tcg/hppa/float_madds.ref        | 64 ++++++++++++++++++++
 tests/tcg/i386/float_madds.ref        | 64 ++++++++++++++++++++
 tests/tcg/loongarch64/float_madds.ref | 64 ++++++++++++++++++++
 tests/tcg/m68k/float_madds.ref        | 64 ++++++++++++++++++++
 tests/tcg/mips/float_madds.ref        | 64 ++++++++++++++++++++
 tests/tcg/mips64/float_madds.ref      | 64 ++++++++++++++++++++
 tests/tcg/mips64el/float_madds.ref    | 64 ++++++++++++++++++++
 tests/tcg/mipsel/float_madds.ref      | 64 ++++++++++++++++++++
 tests/tcg/or1k/float_madds.ref        | 16 +++++
 tests/tcg/ppc64/float_madds.ref       | 64 ++++++++++++++++++++
 tests/tcg/ppc64le/float_madds.ref     | 64 ++++++++++++++++++++
 tests/tcg/riscv64/float_madds.ref     | 64 ++++++++++++++++++++
 tests/tcg/s390x/float_madds.ref       | 64 ++++++++++++++++++++
 tests/tcg/sh4/float_madds.ref         | 32 ++++++++++
 tests/tcg/x86_64/float_madds.ref      | 64 ++++++++++++++++++++
 23 files changed, 1247 insertions(+)
 create mode 100755 scripts/tests/regen-reference.sh

-- 
2.47.3



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

* [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts
  2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
@ 2026-11-30 20:16 ` Alex Bennée
  2026-11-30 20:34   ` Pierrick Bouvier
  2026-11-30 20:16 ` [PATCH 2/4] scripts/tests: add regen-reference.sh Alex Bennée
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Alex Bennée, Marc-André Lureau,
	Peter Maydell, Philippe Mathieu-Daudé, Xianglai Li,
	qemu-riscv, qemu-arm, Daniel Henrique Barboza, qemu-ppc,
	Brian Cain, Nicholas Piggin, Ilya Leoshkevich, Alistair Francis,
	Helge Deller, Weiwei Li, Richard Henderson, Aurelien Jarno,
	Chao Liu, Pierrick Bouvier, Palmer Dabbelt, Stafford Horne,
	Glenn Miles, Harsh Prateek Bora, Chinmay Rath, Paolo Bonzini,
	Bibo Mao

If we are mandating using the ./run wrapper when calling scripts we
should also expose the source root to save scripts having to jump
hoops to find it.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 meson.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/meson.build b/meson.build
index f8dd3926dd8..a74e82222c9 100644
--- a/meson.build
+++ b/meson.build
@@ -3501,6 +3501,7 @@ config_host_h = configure_file(output: 'config-host.h', configuration: config_ho
 genh += config_host_h
 
 devenv = environment()
+devenv.set('MESON_SOURCE_ROOT', meson.project_source_root())
 devenv.set('MESON_BUILD_ROOT', meson.project_build_root())
 devenv.set('VIRTUAL_ENV', meson.project_build_root() / 'pyvenv')
 devenv.prepend('PATH', meson.project_build_root() / 'pyvenv'/ 'bin')
-- 
2.47.3



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

* [PATCH 2/4] scripts/tests: add regen-reference.sh
  2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
  2026-11-30 20:16 ` [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts Alex Bennée
@ 2026-11-30 20:16 ` Alex Bennée
  2026-11-30 20:34   ` Pierrick Bouvier
  2026-11-30 20:16 ` [PATCH 3/4] tests/tcg: extend the float_madds test case Alex Bennée
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Alex Bennée, Marc-André Lureau,
	Peter Maydell, Philippe Mathieu-Daudé, Xianglai Li,
	qemu-riscv, qemu-arm, Daniel Henrique Barboza, qemu-ppc,
	Brian Cain, Nicholas Piggin, Ilya Leoshkevich, Alistair Francis,
	Helge Deller, Weiwei Li, Richard Henderson, Aurelien Jarno,
	Chao Liu, Pierrick Bouvier, Palmer Dabbelt, Stafford Horne,
	Glenn Miles, Harsh Prateek Bora, Chinmay Rath, Paolo Bonzini,
	Bibo Mao

While we should verify references with real hardware we don't have
hardware for all cases. Since the meson conversion we've made
reference files mandatory so lets include a helper script to make
things a bit easier to update.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 scripts/tests/regen-reference.sh   | 87 ++++++++++++++++++++++++++++++
 tests/tcg/mips64/float_madds.ref   | 64 ++++++++++++++++++++++
 tests/tcg/mips64el/float_madds.ref | 64 ++++++++++++++++++++++
 tests/tcg/mipsel/float_madds.ref   | 64 ++++++++++++++++++++++
 tests/tcg/or1k/float_madds.ref     | 16 ++++++
 tests/tcg/ppc64/float_madds.ref    | 64 ++++++++++++++++++++++
 tests/tcg/riscv64/float_madds.ref  | 64 ++++++++++++++++++++++
 7 files changed, 423 insertions(+)
 create mode 100755 scripts/tests/regen-reference.sh

diff --git a/scripts/tests/regen-reference.sh b/scripts/tests/regen-reference.sh
new file mode 100755
index 00000000000..0600b56bef8
--- /dev/null
+++ b/scripts/tests/regen-reference.sh
@@ -0,0 +1,87 @@
+#!/bin/sh
+#
+# Regenerate TCG test reference files.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+set -eu
+
+usage() {
+    cat <<EOF
+Usage: ./run $(basename "$0") [-n] <test-name-or-stub>
+
+Regenerate TCG reference (.ref) files for tests matching <test-name-or-stub>.
+This script must be executed from inside a QEMU build directory using the './run' wrapper.
+
+Options:
+  -n         Dry run (print commands without executing or overwriting files)
+  -h         Show this help message
+EOF
+    exit "${1:-1}"
+}
+
+DRY_RUN=0
+
+while getopts "nh" opt; do
+    case "$opt" in
+        n) DRY_RUN=1 ;;
+        h) usage 0 ;;
+        *) usage 1 ;;
+    esac
+done
+shift $((OPTIND - 1))
+
+if [ $# -lt 1 ]; then
+    usage 1
+fi
+
+TEST_PATTERN="$1"
+
+# Must be run using the ./run wrapper which provides MESON_SOURCE_ROOT and MESON_BUILD_ROOT
+if [ -z "${MESON_SOURCE_ROOT:-}" ] || [ -z "${MESON_BUILD_ROOT:-}" ]; then
+    echo "Error: MESON_SOURCE_ROOT or MESON_BUILD_ROOT is not set." >&2
+    echo "This script must be executed from inside a build directory using the './run' wrapper, e.g.:" >&2
+    echo "  cd <build-dir> && ./run \$PWD/../scripts/tests/regen-reference.sh ${TEST_PATTERN}" >&2
+    exit 1
+fi
+
+SRC_ROOT="$MESON_SOURCE_ROOT"
+BUILD_DIR="$MESON_BUILD_ROOT"
+
+# Ensure we are inside the build directory
+if [ ! -f "build.ninja" ] || [ "$(pwd -P)" != "$(cd "$BUILD_DIR" && pwd -P)" ]; then
+    echo "Error: This script must be executed from inside the build directory." >&2
+    echo "Please cd into your build directory and run via './run'." >&2
+    exit 1
+fi
+
+echo "!!! Warning: about to regenerate with TCG !!!"
+echo "You should verify the real hardware generates the same reference files where you can"
+
+# Query meson test list
+TEST_LIST=$(meson test --suite tcg --list "*${TEST_PATTERN}*" | grep -v "plugin")
+
+while IFS= read -r line; do
+    case "$line" in
+        *" / "*)
+            test_name="${line##* / }"
+            case "$test_name" in
+                *-linux-user-*)
+                    arch="${test_name%%-linux-user-*}"
+                    test_base="${test_name#*-linux-user-}"
+
+                    qemu_bin="./qemu-${arch}"
+                    test_bin="tests/tcg/${test_name}.test"
+                    ref_file="${SRC_ROOT}/tests/tcg/${arch}/${test_base}.ref"
+
+                    echo "${qemu_bin} ${test_bin} > ${ref_file}"
+                    if [ "$DRY_RUN" -eq 0 ]; then
+                        "${qemu_bin}" "${test_bin}" > "${ref_file}"
+                    fi
+                    ;;
+            esac
+            ;;
+    esac
+done <<EOF
+$TEST_LIST
+EOF
diff --git a/tests/tcg/mips64/float_madds.ref b/tests/tcg/mips64/float_madds.ref
index 2020c65d18e..b6eb0463eeb 100644
--- a/tests/tcg/mips64/float_madds.ref
+++ b/tests/tcg/mips64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/mips64el/float_madds.ref b/tests/tcg/mips64el/float_madds.ref
index 2020c65d18e..b6eb0463eeb 100644
--- a/tests/tcg/mips64el/float_madds.ref
+++ b/tests/tcg/mips64el/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/mipsel/float_madds.ref b/tests/tcg/mipsel/float_madds.ref
index 2020c65d18e..b6eb0463eeb 100644
--- a/tests/tcg/mipsel/float_madds.ref
+++ b/tests/tcg/mipsel/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/or1k/float_madds.ref b/tests/tcg/or1k/float_madds.ref
index 2c7c35c8b47..b94d65c19e4 100644
--- a/tests/tcg/or1k/float_madds.ref
+++ b/tests/tcg/or1k/float_madds.ref
@@ -190,3 +190,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=OK (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=OK (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=OK (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=OK (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=OK (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=OK (39/0)
diff --git a/tests/tcg/ppc64/float_madds.ref b/tests/tcg/ppc64/float_madds.ref
index e66917cb801..a2f236127fd 100644
--- a/tests/tcg/ppc64/float_madds.ref
+++ b/tests/tcg/ppc64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/riscv64/float_madds.ref b/tests/tcg/riscv64/float_madds.ref
index 5fe00031203..f534cdf7be3 100644
--- a/tests/tcg/riscv64/float_madds.ref
+++ b/tests/tcg/riscv64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(nan:0xffa00000) * f32(nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(nan:0x7fc00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(nan:0xffa00000) * f32(nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(nan:0x7fc00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffa00000) * f32(nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(nan:0x7fc00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
-- 
2.47.3



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

* [PATCH 3/4] tests/tcg: extend the float_madds test case
  2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
  2026-11-30 20:16 ` [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts Alex Bennée
  2026-11-30 20:16 ` [PATCH 2/4] scripts/tests: add regen-reference.sh Alex Bennée
@ 2026-11-30 20:16 ` Alex Bennée
  2026-11-30 20:34   ` Pierrick Bouvier
  2026-11-30 20:16 ` [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf Alex Bennée
  2026-11-30 20:36 ` [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Pierrick Bouvier
  4 siblings, 1 reply; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Alex Bennée, Marc-André Lureau,
	Peter Maydell, Philippe Mathieu-Daudé, Xianglai Li,
	qemu-riscv, qemu-arm, Daniel Henrique Barboza, qemu-ppc,
	Brian Cain, Nicholas Piggin, Ilya Leoshkevich, Alistair Francis,
	Helge Deller, Weiwei Li, Richard Henderson, Aurelien Jarno,
	Chao Liu, Pierrick Bouvier, Palmer Dabbelt, Stafford Horne,
	Glenn Miles, Harsh Prateek Bora, Chinmay Rath, Paolo Bonzini,
	Bibo Mao

We have a bug report about a failing case when using a broken
mingw-w64 and in the upstream bug there where some additional test
cases added. Import them into our *-user test so we can verify the fix
later.

I've regenerated the references with the new TCG helper script but I
have verified they are correct for arm, aarch64, ppc64 and s390x.

BugLink: https://sourceforge.net/p/mingw-w64/bugs/848/
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 tests/tcg/multiarch/float_madds.c     | 13 ++++++
 tests/tcg/aarch64/float_madds.ref     | 64 +++++++++++++++++++++++++++
 tests/tcg/alpha/float_madds.ref       | 64 +++++++++++++++++++++++++++
 tests/tcg/arm/float_madds.ref         | 64 +++++++++++++++++++++++++++
 tests/tcg/hexagon/float_madds.ref     | 64 +++++++++++++++++++++++++++
 tests/tcg/hppa/float_madds.ref        | 64 +++++++++++++++++++++++++++
 tests/tcg/i386/float_madds.ref        | 64 +++++++++++++++++++++++++++
 tests/tcg/loongarch64/float_madds.ref | 64 +++++++++++++++++++++++++++
 tests/tcg/m68k/float_madds.ref        | 64 +++++++++++++++++++++++++++
 tests/tcg/mips/float_madds.ref        | 64 +++++++++++++++++++++++++++
 tests/tcg/ppc64le/float_madds.ref     | 64 +++++++++++++++++++++++++++
 tests/tcg/s390x/float_madds.ref       | 64 +++++++++++++++++++++++++++
 tests/tcg/sh4/float_madds.ref         | 32 ++++++++++++++
 tests/tcg/x86_64/float_madds.ref      | 64 +++++++++++++++++++++++++++
 14 files changed, 813 insertions(+)

diff --git a/tests/tcg/multiarch/float_madds.c b/tests/tcg/multiarch/float_madds.c
index a692e052d5b..47d9847b573 100644
--- a/tests/tcg/multiarch/float_madds.c
+++ b/tests/tcg/multiarch/float_madds.c
@@ -99,6 +99,19 @@ int main(int argc, char *argv[argc])
         printf("# LP184149\n");
         do_madds(0x1.ffffffffffffcp-1022, 0x1.0000000000001p-1, 0x0.0000000000001p-1022, j, 0);
         do_madds(0x8p-152, 0x8p-152, 0x8p-152, j+1, 0);
+
+        /* From https://gitlab.com/qemu-project/qemu/-/issues/5023 */
+        printf("# Issue 5023\n");
+        do_madds(FLT_MAX, 2.0f, -FLT_MAX, j+2, 0);
+
+        /* From https://gist.github.com/minoki/ff4412f2a385eab3c7e689acd589ea3e */
+        printf("# Gist cases\n");
+        do_madds(0x1p100f, 0x1p100f, -INFINITY, j+3, 0);
+        do_madds(0x1.fffffep23f, 0x1.000004p28f, 0x1.fcp5f, j+4, 0);
+        do_madds(0x1.84ae3p125f, 0x1.6p-141f, 0x1p-149f, j+5, 0);
+        do_madds(0x1.00001p50f, 0x1.1p50f, 0x1p-149f, j+6, 0);
+        do_madds(0x1.000002p50f, 0x1.8p50f, -0x1p-149f, j+7, 0);
+        do_madds(0x1.83bd78p4f, -0x1.cp118f, -0x1.344108p-2f, j+8, 0);
     }
 
     return 0;
diff --git a/tests/tcg/aarch64/float_madds.ref b/tests/tcg/aarch64/float_madds.ref
index 21c05398878..83f451ef1da 100644
--- a/tests/tcg/aarch64/float_madds.ref
+++ b/tests/tcg/aarch64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/alpha/float_madds.ref b/tests/tcg/alpha/float_madds.ref
index 76996f432db..ae85eb24369 100644
--- a/tests/tcg/alpha/float_madds.ref
+++ b/tests/tcg/alpha/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/arm/float_madds.ref b/tests/tcg/arm/float_madds.ref
index 21c05398878..83f451ef1da 100644
--- a/tests/tcg/arm/float_madds.ref
+++ b/tests/tcg/arm/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/hexagon/float_madds.ref b/tests/tcg/hexagon/float_madds.ref
index a08c6160574..63585ff0dce 100644
--- a/tests/tcg/hexagon/float_madds.ref
+++ b/tests/tcg/hexagon/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/hppa/float_madds.ref b/tests/tcg/hppa/float_madds.ref
index b4b65f83aed..8453c191988 100644
--- a/tests/tcg/hppa/float_madds.ref
+++ b/tests/tcg/hppa/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffffffff) * f32(-nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffbfffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffffffff) * f32(-nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffbfffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffffffff) * f32(-nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffbfffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/i386/float_madds.ref b/tests/tcg/i386/float_madds.ref
index bb834699311..eaca70cd21a 100644
--- a/tests/tcg/i386/float_madds.ref
+++ b/tests/tcg/i386/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffe00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=OK (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffe00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=OK (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffe00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=OK (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/loongarch64/float_madds.ref b/tests/tcg/loongarch64/float_madds.ref
index 21c05398878..83f451ef1da 100644
--- a/tests/tcg/loongarch64/float_madds.ref
+++ b/tests/tcg/loongarch64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/m68k/float_madds.ref b/tests/tcg/m68k/float_madds.ref
index 23a1357a590..44c32bf5c24 100644
--- a/tests/tcg/m68k/float_madds.ref
+++ b/tests/tcg/m68k/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffffffff) * f32(-nan:0xffffffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffffffff) * f32(-nan:0xffffffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffffffff) * f32(-nan:0xffffffff) + f32(-inf:0xff800000)
 res: f32(-nan:0xffffffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/mips/float_madds.ref b/tests/tcg/mips/float_madds.ref
index 2020c65d18e..b6eb0463eeb 100644
--- a/tests/tcg/mips/float_madds.ref
+++ b/tests/tcg/mips/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffffffff) * f32(nan:0xffbfffff) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/ppc64le/float_madds.ref b/tests/tcg/ppc64le/float_madds.ref
index e66917cb801..a2f236127fd 100644
--- a/tests/tcg/ppc64le/float_madds.ref
+++ b/tests/tcg/ppc64le/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/s390x/float_madds.ref b/tests/tcg/s390x/float_madds.ref
index 451cbec624d..1d3927fd8f1 100644
--- a/tests/tcg/s390x/float_madds.ref
+++ b/tests/tcg/s390x/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffe00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/sh4/float_madds.ref b/tests/tcg/sh4/float_madds.ref
index 6d96a2a5929..ceed6008ff8 100644
--- a/tests/tcg/sh4/float_madds.ref
+++ b/tests/tcg/sh4/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(nan:0xffa00000) * f32(nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(nan:0x7fbfffff) flags=INVALID (0/0)
@@ -382,3 +398,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
diff --git a/tests/tcg/x86_64/float_madds.ref b/tests/tcg/x86_64/float_madds.ref
index 79419f003e7..7bbcbab7975 100644
--- a/tests/tcg/x86_64/float_madds.ref
+++ b/tests/tcg/x86_64/float_madds.ref
@@ -190,6 +190,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding upwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=INVALID (0/0)
@@ -382,6 +398,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-148:0x00000002) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000400000000000000p+52:0x59800002) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c200000000000000p-15:0x38059be1) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001200000000000000p+100:0x71880009) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000400000000000000p+100:0x71c00002) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
 ### Rounding downwards
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=INVALID (0/0)
@@ -574,6 +606,22 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345ca00000000000000p+123:0xfd29a2e5) flags=INEXACT  (39/0)
 ### Rounding to zero
 op : f32(-nan:0xffa00000) * f32(-nan:0xffc00000) + f32(-inf:0xff800000)
 res: f32(-nan:0xffc00000) flags=INVALID (0/0)
@@ -766,3 +814,19 @@ op : f32(0x0.00000000000000000000p+0:0000000000) * f32(0x1.00000000000000000000p
 res: f32(0x0.00000000000000000000p+0:0000000000) flags=OK (31/0)
 op : f32(0x1.00000000000000000000p-149:0x00000001) * f32(0x1.00000000000000000000p-149:0x00000001) + f32(0x1.00000000000000000000p-149:0x00000001)
 res: f32(0x1.00000000000000000000p-149:0x00000001) flags=UNDERFLOW INEXACT  (32/0)
+# Issue 5023
+op : f32(0x1.fffffe00000000000000p+127:0x7f7fffff) * f32(0x1.00000000000000000000p+1:0x40000000) + f32(-0x1.fffffe00000000000000p+127:0xff7fffff)
+res: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) flags=OK (33/0)
+# Gist cases
+op : f32(0x1.00000000000000000000p+100:0x71800000) * f32(0x1.00000000000000000000p+100:0x71800000) + f32(-inf:0xff800000)
+res: f32(-inf:0xff800000) flags=OK (34/0)
+op : f32(0x1.fffffe00000000000000p+23:0x4b7fffff) * f32(0x1.00000400000000000000p+28:0x4d800002) + f32(0x1.fc000000000000000000p+5:0x427e0000)
+res: f32(0x1.00000200000000000000p+52:0x59800001) flags=INEXACT  (35/0)
+op : f32(0x1.84ae3000000000000000p+125:0x7e425718) * f32(0x1.60000000000000000000p-141:0x00000160) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.0b37c000000000000000p-15:0x38059be0) flags=INEXACT  (36/0)
+op : f32(0x1.00001000000000000000p+50:0x58800008) * f32(0x1.10000000000000000000p+50:0x58880000) + f32(0x1.00000000000000000000p-149:0x00000001)
+res: f32(0x1.10001000000000000000p+100:0x71880008) flags=INEXACT  (37/0)
+op : f32(0x1.00000200000000000000p+50:0x58800001) * f32(0x1.80000000000000000000p+50:0x58c00000) + f32(-0x1.00000000000000000000p-149:0x80000001)
+res: f32(0x1.80000200000000000000p+100:0x71c00001) flags=INEXACT  (38/0)
+op : f32(0x1.83bd7800000000000000p+4:0x41c1debc) * f32(-0x1.c0000000000000000000p+118:0xfae00000) + f32(-0x1.34410800000000000000p-2:0xbe9a2084)
+res: f32(-0x1.5345c800000000000000p+123:0xfd29a2e4) flags=INEXACT  (39/0)
-- 
2.47.3



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

* [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf
  2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
                   ` (2 preceding siblings ...)
  2026-11-30 20:16 ` [PATCH 3/4] tests/tcg: extend the float_madds test case Alex Bennée
@ 2026-11-30 20:16 ` Alex Bennée
  2026-11-30 20:35   ` Pierrick Bouvier
  2026-11-30 20:36 ` [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Pierrick Bouvier
  4 siblings, 1 reply; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 20:16 UTC (permalink / raw)
  To: qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Alex Bennée, Marc-André Lureau,
	Peter Maydell, Philippe Mathieu-Daudé, Xianglai Li,
	qemu-riscv, qemu-arm, Daniel Henrique Barboza, qemu-ppc,
	Brian Cain, Nicholas Piggin, Ilya Leoshkevich, Alistair Francis,
	Helge Deller, Weiwei Li, Richard Henderson, Aurelien Jarno,
	Chao Liu, Pierrick Bouvier, Palmer Dabbelt, Stafford Horne,
	Glenn Miles, Harsh Prateek Bora, Chinmay Rath, Paolo Bonzini,
	Bibo Mao

We already had a test against fma to catch broken glibc's but
apparently there are mingw64 cases that are broken for fmaf on
Windows. Add a test to softfloat_init so we can disable if we detect
the brokenness.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5023
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 fpu/softfloat.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index bc244a44ffb..4531de5e6cf 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5161,4 +5161,14 @@ static void __attribute__((constructor)) softfloat_init(void)
     if (ur.s != 0x0020000000000001ULL) {
         force_soft_fma = true;
     }
+
+    /*
+     * Test that the host's fmaf is not obviously broken. For example,
+     * mingw-w64 can perform an incorrect fmaf on certain hosts; see
+     *   https://gitlab.com/qemu-project/qemu/-/issues/5023
+     *   https://sourceforge.net/p/mingw-w64/bugs/848/
+     */
+    if (fmaf(FLT_MAX, 2.0f, -FLT_MAX) != FLT_MAX) {
+        force_soft_fma = true;
+    }
 }
-- 
2.47.3



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

* Re: [PATCH 2/4] scripts/tests: add regen-reference.sh
  2026-11-30 20:16 ` [PATCH 2/4] scripts/tests: add regen-reference.sh Alex Bennée
@ 2026-11-30 20:34   ` Pierrick Bouvier
  0 siblings, 0 replies; 11+ messages in thread
From: Pierrick Bouvier @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

On 11/30/2026 12:16 PM, Alex Bennée wrote:
> While we should verify references with real hardware we don't have
> hardware for all cases. Since the meson conversion we've made
> reference files mandatory so lets include a helper script to make
> things a bit easier to update.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  scripts/tests/regen-reference.sh   | 87 ++++++++++++++++++++++++++++++
>  tests/tcg/mips64/float_madds.ref   | 64 ++++++++++++++++++++++
>  tests/tcg/mips64el/float_madds.ref | 64 ++++++++++++++++++++++
>  tests/tcg/mipsel/float_madds.ref   | 64 ++++++++++++++++++++++
>  tests/tcg/or1k/float_madds.ref     | 16 ++++++
>  tests/tcg/ppc64/float_madds.ref    | 64 ++++++++++++++++++++++
>  tests/tcg/riscv64/float_madds.ref  | 64 ++++++++++++++++++++++

Seems like refs update belong to next commit.

>  7 files changed, 423 insertions(+)
>  create mode 100755 scripts/tests/regen-reference.sh
> 
> diff --git a/scripts/tests/regen-reference.sh b/scripts/tests/regen-reference.sh
> new file mode 100755
> index 00000000000..0600b56bef8
> --- /dev/null
> +++ b/scripts/tests/regen-reference.sh
> @@ -0,0 +1,87 @@
> +#!/bin/sh
> +#
> +# Regenerate TCG test reference files.
> +#
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +
> +set -eu
> +
> +usage() {
> +    cat <<EOF
> +Usage: ./run $(basename "$0") [-n] <test-name-or-stub>
> +
> +Regenerate TCG reference (.ref) files for tests matching <test-name-or-stub>.
> +This script must be executed from inside a QEMU build directory using the './run' wrapper.
> +
> +Options:
> +  -n         Dry run (print commands without executing or overwriting files)
> +  -h         Show this help message
> +EOF
> +    exit "${1:-1}"
> +}
> +
> +DRY_RUN=0
> +
> +while getopts "nh" opt; do
> +    case "$opt" in
> +        n) DRY_RUN=1 ;;
> +        h) usage 0 ;;
> +        *) usage 1 ;;
> +    esac
> +done
> +shift $((OPTIND - 1))
> +
> +if [ $# -lt 1 ]; then
> +    usage 1
> +fi
> +
> +TEST_PATTERN="$1"
> +
> +# Must be run using the ./run wrapper which provides MESON_SOURCE_ROOT and MESON_BUILD_ROOT
> +if [ -z "${MESON_SOURCE_ROOT:-}" ] || [ -z "${MESON_BUILD_ROOT:-}" ]; then
> +    echo "Error: MESON_SOURCE_ROOT or MESON_BUILD_ROOT is not set." >&2
> +    echo "This script must be executed from inside a build directory using the './run' wrapper, e.g.:" >&2
> +    echo "  cd <build-dir> && ./run \$PWD/../scripts/tests/regen-reference.sh ${TEST_PATTERN}" >&2
> +    exit 1
> +fi
> +
> +SRC_ROOT="$MESON_SOURCE_ROOT"
> +BUILD_DIR="$MESON_BUILD_ROOT"
> +
> +# Ensure we are inside the build directory
> +if [ ! -f "build.ninja" ] || [ "$(pwd -P)" != "$(cd "$BUILD_DIR" && pwd -P)" ]; then
> +    echo "Error: This script must be executed from inside the build directory." >&2
> +    echo "Please cd into your build directory and run via './run'." >&2
> +    exit 1
> +fi
> +
> +echo "!!! Warning: about to regenerate with TCG !!!"
> +echo "You should verify the real hardware generates the same reference files where you can"
> +
> +# Query meson test list
> +TEST_LIST=$(meson test --suite tcg --list "*${TEST_PATTERN}*" | grep -v "plugin")
> +
> +while IFS= read -r line; do
> +    case "$line" in
> +        *" / "*)
> +            test_name="${line##* / }"
> +            case "$test_name" in
> +                *-linux-user-*)
> +                    arch="${test_name%%-linux-user-*}"
> +                    test_base="${test_name#*-linux-user-}"
> +
> +                    qemu_bin="./qemu-${arch}"
> +                    test_bin="tests/tcg/${test_name}.test"
> +                    ref_file="${SRC_ROOT}/tests/tcg/${arch}/${test_base}.ref"
> +
> +                    echo "${qemu_bin} ${test_bin} > ${ref_file}"
> +                    if [ "$DRY_RUN" -eq 0 ]; then
> +                        "${qemu_bin}" "${test_bin}" > "${ref_file}"
> +                    fi
> +                    ;;
> +            esac
> +            ;;
> +    esac
> +done <<EOF
> +$TEST_LIST
> +EOF
Good idea.

Let's make it simpler:
- rename it regen-float-references.sh
- no arguments (always cover all the tests available)
- always rebuild by default (ninja tcg-tests) to make sure everything is
up to date

This way it's bulletproof and impossible to miss anything.

Regards,
Pierrick


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

* Re: [PATCH 3/4] tests/tcg: extend the float_madds test case
  2026-11-30 20:16 ` [PATCH 3/4] tests/tcg: extend the float_madds test case Alex Bennée
@ 2026-11-30 20:34   ` Pierrick Bouvier
  0 siblings, 0 replies; 11+ messages in thread
From: Pierrick Bouvier @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

On 11/30/2026 12:16 PM, Alex Bennée wrote:
> We have a bug report about a failing case when using a broken
> mingw-w64 and in the upstream bug there where some additional test
> cases added. Import them into our *-user test so we can verify the fix
> later.
> 
> I've regenerated the references with the new TCG helper script but I
> have verified they are correct for arm, aarch64, ppc64 and s390x.
> 
> BugLink: https://sourceforge.net/p/mingw-w64/bugs/848/
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  tests/tcg/multiarch/float_madds.c     | 13 ++++++
>  tests/tcg/aarch64/float_madds.ref     | 64 +++++++++++++++++++++++++++
>  tests/tcg/alpha/float_madds.ref       | 64 +++++++++++++++++++++++++++
>  tests/tcg/arm/float_madds.ref         | 64 +++++++++++++++++++++++++++
>  tests/tcg/hexagon/float_madds.ref     | 64 +++++++++++++++++++++++++++
>  tests/tcg/hppa/float_madds.ref        | 64 +++++++++++++++++++++++++++
>  tests/tcg/i386/float_madds.ref        | 64 +++++++++++++++++++++++++++
>  tests/tcg/loongarch64/float_madds.ref | 64 +++++++++++++++++++++++++++
>  tests/tcg/m68k/float_madds.ref        | 64 +++++++++++++++++++++++++++
>  tests/tcg/mips/float_madds.ref        | 64 +++++++++++++++++++++++++++
>  tests/tcg/ppc64le/float_madds.ref     | 64 +++++++++++++++++++++++++++
>  tests/tcg/s390x/float_madds.ref       | 64 +++++++++++++++++++++++++++
>  tests/tcg/sh4/float_madds.ref         | 32 ++++++++++++++
>  tests/tcg/x86_64/float_madds.ref      | 64 +++++++++++++++++++++++++++
>  14 files changed, 813 insertions(+)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>


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

* Re: [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts
  2026-11-30 20:16 ` [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts Alex Bennée
@ 2026-11-30 20:34   ` Pierrick Bouvier
  0 siblings, 0 replies; 11+ messages in thread
From: Pierrick Bouvier @ 2026-11-30 20:34 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

On 11/30/2026 12:16 PM, Alex Bennée wrote:
> If we are mandating using the ./run wrapper when calling scripts we
> should also expose the source root to save scripts having to jump
> hoops to find it.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  meson.build | 1 +
>  1 file changed, 1 insertion(+)
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>


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

* Re: [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf
  2026-11-30 20:16 ` [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf Alex Bennée
@ 2026-11-30 20:35   ` Pierrick Bouvier
  0 siblings, 0 replies; 11+ messages in thread
From: Pierrick Bouvier @ 2026-11-30 20:35 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

On 11/30/2026 12:16 PM, Alex Bennée wrote:
> We already had a test against fma to catch broken glibc's but
> apparently there are mingw64 cases that are broken for fmaf on
> Windows. Add a test to softfloat_init so we can disable if we detect
> the brokenness.
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/5023
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  fpu/softfloat.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index bc244a44ffb..4531de5e6cf 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -5161,4 +5161,14 @@ static void __attribute__((constructor)) softfloat_init(void)
>      if (ur.s != 0x0020000000000001ULL) {
>          force_soft_fma = true;
>      }
> +
> +    /*
> +     * Test that the host's fmaf is not obviously broken. For example,
> +     * mingw-w64 can perform an incorrect fmaf on certain hosts; see
> +     *   https://gitlab.com/qemu-project/qemu/-/issues/5023
> +     *   https://sourceforge.net/p/mingw-w64/bugs/848/
> +     */
> +    if (fmaf(FLT_MAX, 2.0f, -FLT_MAX) != FLT_MAX) {
> +        force_soft_fma = true;
> +    }
>  }

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>



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

* Re: [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203
  2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
                   ` (3 preceding siblings ...)
  2026-11-30 20:16 ` [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf Alex Bennée
@ 2026-11-30 20:36 ` Pierrick Bouvier
  2026-11-30 22:27   ` Alex Bennée
  4 siblings, 1 reply; 11+ messages in thread
From: Pierrick Bouvier @ 2026-11-30 20:36 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel
  Cc: Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei, qemu-s390x,
	Aleksandar Rikalo, David Hildenbrand, Laurent Vivier, Song Gao,
	Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

Hi Alex,

On 11/30/2026 12:16 PM, Alex Bennée wrote:
> We had a bug reported that fma fails on some platforms. I can't test
> the fix but I took the opportunity to extend the TCG test cases to
> cover a few more of the fma corner cases along with what is hopefully
> the fix.
> 

would that be a 11.2 candidate?

Regards,
Pierrick


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

* Re: [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203
  2026-11-30 20:36 ` [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Pierrick Bouvier
@ 2026-11-30 22:27   ` Alex Bennée
  0 siblings, 0 replies; 11+ messages in thread
From: Alex Bennée @ 2026-11-30 22:27 UTC (permalink / raw)
  To: Pierrick Bouvier
  Cc: qemu-devel, Daniel P. Berrangé, Yoshinori Sato, Liu Zhiwei,
	qemu-s390x, Aleksandar Rikalo, David Hildenbrand, Laurent Vivier,
	Song Gao, Jiaxun Yang, Marc-André Lureau, Peter Maydell,
	Philippe Mathieu-Daudé, Xianglai Li, qemu-riscv, qemu-arm,
	Daniel Henrique Barboza, qemu-ppc, Brian Cain, Nicholas Piggin,
	Ilya Leoshkevich, Alistair Francis, Helge Deller, Weiwei Li,
	Richard Henderson, Aurelien Jarno, Chao Liu, Palmer Dabbelt,
	Stafford Horne, Glenn Miles, Harsh Prateek Bora, Chinmay Rath,
	Paolo Bonzini, Bibo Mao

Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com> writes:

> Hi Alex,
>
> On 11/30/2026 12:16 PM, Alex Bennée wrote:
>> We had a bug reported that fma fails on some platforms. I can't test
>> the fix but I took the opportunity to extend the TCG test cases to
>> cover a few more of the fma corner cases along with what is hopefully
>> the fix.
>> 
>
> would that be a 11.2 candidate?

Possibly - it depends if the reporter thinks 4/4 has fixed things. The
tests are OK to wait until the next release. In fact to properly
exercise things we'd want a system mode version (as Windows can't run
*-user) and I realise now the test case will never exercise hardfloat as
the flags are reset for each calculation.

>
> Regards,
> Pierrick

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


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

end of thread, other threads:[~2026-11-30 22:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 20:16 [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Alex Bennée
2026-11-30 20:16 ` [PATCH 1/4] meson: expose MESON_SOURCE_ROOT to scripts Alex Bennée
2026-11-30 20:34   ` Pierrick Bouvier
2026-11-30 20:16 ` [PATCH 2/4] scripts/tests: add regen-reference.sh Alex Bennée
2026-11-30 20:34   ` Pierrick Bouvier
2026-11-30 20:16 ` [PATCH 3/4] tests/tcg: extend the float_madds test case Alex Bennée
2026-11-30 20:34   ` Pierrick Bouvier
2026-11-30 20:16 ` [PATCH 4/4] fpu/softfloat: gate hardfloat on working fmaf Alex Bennée
2026-11-30 20:35   ` Pierrick Bouvier
2026-11-30 20:36 ` [PATCH 0/4] [soft|hard]float: tests and bug fix for #5203 Pierrick Bouvier
2026-11-30 22:27   ` 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.