diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2025-05-06 19:25:54 +0000 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2025-07-10 11:53:10 -0600 |
| commit | abbeb42c1762a529cfbae52845c279b648a7acb4 (patch) | |
| tree | 8b742d60b1efa1b55c0d0e3f4350f10beb8e56ae /tests | |
| parent | df6fe2abf2e990f767ce755d426bc439c7bba336 (diff) | |
| download | focaccia-qemu-abbeb42c1762a529cfbae52845c279b648a7acb4.tar.gz focaccia-qemu-abbeb42c1762a529cfbae52845c279b648a7acb4.zip | |
fpu: Process float_muladd_negate_result after rounding
Changing the sign before rounding affects the correctness of the asymmetric rouding modes: float_round_up and float_round_down. Reported-by: WANG Rui <wangrui@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tcg/multiarch/Makefile.target | 1 | ||||
| -rw-r--r-- | tests/tcg/multiarch/fnmsub.c | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/tcg/multiarch/Makefile.target b/tests/tcg/multiarch/Makefile.target index 45c9cfe18c..bfdf7197a7 100644 --- a/tests/tcg/multiarch/Makefile.target +++ b/tests/tcg/multiarch/Makefile.target @@ -29,6 +29,7 @@ run-float_%: float_% $(call run-test,$<, $(QEMU) $(QEMU_OPTS) $<) $(call conditional-diff-out,$<,$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/$<.ref) +fnmsub: LDFLAGS+=-lm testthread: LDFLAGS+=-lpthread diff --git a/tests/tcg/multiarch/fnmsub.c b/tests/tcg/multiarch/fnmsub.c new file mode 100644 index 0000000000..15dd41d3bd --- /dev/null +++ b/tests/tcg/multiarch/fnmsub.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <stdio.h> +#include <math.h> +#include <fenv.h> + +union U { + double d; + unsigned long long l; +}; + +union U x = { .l = 0x4ff0000000000000ULL }; +union U y = { .l = 0x2ff0000000000000ULL }; +union U r; + +int main() +{ +#ifdef FE_DOWNWARD + fesetround(FE_DOWNWARD); + +#if defined(__loongarch__) + asm("fnmsub.d %0, %1, %1, %2" : "=f"(r.d) : "f"(x.d), "f"(y.d)); +#elif defined(__powerpc64__) + asm("fnmsub %0,%1,%1,%2" : "=f"(r.d) : "f"(x.d), "f"(y.d)); +#elif defined(__s390x__) && 0 /* need -march=z14 */ + asm("vfnms %0,%1,%1,%2,0,3" : "=f"(r.d) : "f"(x.d), "f"(y.d)); +#else + r.d = -fma(x.d, x.d, -y.d); +#endif + + if (r.l != 0xdfefffffffffffffULL) { + printf("r = %.18a (%016llx)\n", r.d, r.l); + return 1; + } +#endif + return 0; +} |