OSDN Git Service

target/ppc: Fix bugs in VSX_CVT_FP_TO_INT and VSX_CVT_FP_TO_INT2 macros
authorJohn Platts <john_platts@hotmail.com>
Fri, 10 Nov 2023 18:41:42 +0000 (18:41 +0000)
committerCédric Le Goater <clg@kaod.org>
Tue, 21 Nov 2023 07:39:58 +0000 (08:39 +0100)
commitd18b0652869a39688d0fd2897bc035b309d1b6e8
treee174c127967ec4da22e5225e0e9d69bf236d65eb
parent8bc5ae046d15fcd3e5de65225d5d3a8f1a5a6413
target/ppc: Fix bugs in VSX_CVT_FP_TO_INT and VSX_CVT_FP_TO_INT2 macros

The patch below fixes a bug in the VSX_CVT_FP_TO_INT and VSX_CVT_FP_TO_INT2
macros in target/ppc/fpu_helper.c where a non-NaN floating point value from the
source vector is incorrectly converted to 0, 0x80000000, or 0x8000000000000000
instead of the expected value if a preceding source floating point value from
the same source vector was a NaN.

The bug in the VSX_CVT_FP_TO_INT and VSX_CVT_FP_TO_INT2 macros in
target/ppc/fpu_helper.c was introduced with commit c3f24257e3c0.

This patch also adds a new vsx_f2i_nan test in tests/tcg/ppc64 that checks that
the VSX xvcvspsxws, xvcvspuxws, xvcvspsxds, xvcvspuxds, xvcvdpsxws, xvcvdpuxws,
xvcvdpsxds, and xvcvdpuxds instructions correctly convert non-NaN floating point
values to integer values if the source vector contains NaN floating point values.

Fixes: c3f24257e3c0 ("target/ppc: Clear fpstatus flags on helpers missing it")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1941
Signed-off-by: John Platts <john_platts@hotmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
target/ppc/fpu_helper.c
tests/tcg/ppc64/Makefile.target
tests/tcg/ppc64/vsx_f2i_nan.c [new file with mode: 0644]