target/s390x: vfmin/vfmax fixes
v2 cover target/s390x: vfmin/vfmax fixes
Hi,
Uli has found an issue with finding maximum of different kinds of 0s; I wrote a test and found another one with finding maximum of different kinds of NaNs.
Patches 1 and 2 fix those issues, patch 3 adds a vfmin/vfmax test.
Best regards,
Ilya
v1: https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg01915.html
v1 -> v2: Drop mmap() in the test (Richard).
Ilya Leoshkevich (3):
target/s390x: fix handling of zeroes in vfmin/vfmax target/s390x: fix NaN propagation rules tests/tcg/s390x: test signed vfmin/vfmax
fpu/softfloat-specialize.c.inc | 3 +- target/s390x/tcg/vec_fpu_helper.c | 4 +- tests/tcg/s390x/Makefile.target | 7 + tests/tcg/s390x/vfminmax.c | 411 ++++++++++++++++++++++++++++++ 4 files changed, 422 insertions(+), 3 deletions(-) create mode 100644 tests/tcg/s390x/vfminmax.c
Signature · 1 line
2.35.3
PATCH v2 1/3 target/s390x: fix handling of zeroes in vfmin/vfmax
vfmin_res() / vfmax_res() are trying to check whether a and b are both zeroes, but in reality they check that they are the same kind of zero. This causes incorrect results when comparing positive and negative zeroes.
--- target/s390x/tcg/vec_fpu_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/s390x/tcg/vec_fpu_helper.c +2 -2
@@ -824,7 +824,7 @@ static S390MinMaxRes vfmin_res(uint16_t dcmask_a, uint16_t dcmask_b,default :g_assert_not_reached (); } - }else if (unlikely (dcmask_a & dcmask_b &DCMASK_ZERO )) { + }else if (unlikely ((dcmask_a &DCMASK_ZERO ) && (dcmask_b &DCMASK_ZERO ))) {switch (type) {case S390_MINMAX_TYPE_JAVA :return neg_a ?S390_MINMAX_RES_A :S390_MINMAX_RES_B ;
@@ -874,7 +874,7 @@ static S390MinMaxRes vfmax_res(uint16_t dcmask_a, uint16_t dcmask_b,default :g_assert_not_reached (); } - }else if (unlikely (dcmask_a & dcmask_b &DCMASK_ZERO )) { + }else if (unlikely ((dcmask_a &DCMASK_ZERO ) && (dcmask_b &DCMASK_ZERO ))) {const bool neg_a = dcmask_a &DCMASK_NEGATIVE ;switch (type) {
Signature · 1 line
2.35.3
PATCH v2 2/3 target/s390x: fix NaN propagation rules
In reply to Ilya Leoshkevichs390x has the same NaN propagation rules as ARM, and not as x86.
--- fpu/softfloat-specialize.c.inc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fpu/softfloat-specialize.c.inc +2 -1
@@ -390,7 +390,8 @@ bool float32_is_signaling_nan(float32 a_, float_status *status) static int pickNaN(FloatClass a_cls, FloatClass b_cls, bool aIsLargerSignificand, float_status *status) { -#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) +#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_HPPA) || \ + defined(TARGET_S390X) /* ARM mandated NaN propagation rules (see FPProcessNaNs()), take * the first of: * 1. A if it is signaling
Signature · 1 line
2.35.3
PATCH v2 3/3 tests/tcg/s390x: test signed vfmin/vfmax
In reply to Ilya LeoshkevichAdd a test to prevent regressions. Try all floating point value sizes and all combinations of floating point value classes. Verify the results against PoP tables, which are represented as close to the original as possible - this produces a lot of checkpatch complaints, but it seems to be justified in this case.
--- tests/tcg/s390x/Makefile.target | 7 + tests/tcg/s390x/vfminmax.c | 411 ++++++++++++++++++++++++++++++++ 2 files changed, 418 insertions(+) create mode 100644 tests/tcg/s390x/vfminmax.c
tests/tcg/s390x/Makefile.target +7 -0
@@ -17,6 +17,13 @@ TESTS+=trap TESTS+=signals-s390x TESTS+=branch-relative-long +Z14_TESTS=vfminmax +vfminmax: LDFLAGS+=-lm +$(Z14_TESTS): CFLAGS+=-march=z14 -O2 + +TESTS+=$(if $(shell $(CC) -march=z14 -S -o /dev/null -xc /dev/null \ + >/dev/null 2>&1 && echo OK),$(Z14_TESTS)) + VECTOR_TESTS=vxeh2_vs VECTOR_TESTS+=vxeh2_vcvt VECTOR_TESTS+=vxeh2_vlstr
tests/tcg/s390x/vfminmax.c new file +411 -0
411 lines not on this page · raw message
Signature · 1 line
2.35.3
Re: [PATCH v2 3/3] tests/tcg/s390x: test signed vfmin/vfmax
Quoted 6 lines · Ilya Leoshkevich
Add a test to prevent regressions. Try all floating point value sizes and all combinations of floating point value classes. Verify the results against PoP tables, which are represented as close to the original as possible - this produces a lot of checkpatch complaints, but it seems to be justified in this case.
Quoted 6 lines
Signed-off-by Ilya Leoshkevich<[email protected]>--- tests/tcg/s390x/Makefile.target | 7 + tests/tcg/s390x/vfminmax.c | 411 ++++++++++++++++++++++++++++++++ 2 files changed, 418 insertions(+)create mode 100644
tests/tcg/s390x/vfminmax.c
r~
Quoted 19 lines · Ilya Leoshkevich
Hi,
Uli has found an issue with finding maximum of different kinds of 0s; I wrote a test and found another one with finding maximum of different kinds of NaNs.
Patches 1 and 2 fix those issues, patch 3 adds a vfmin/vfmax test.
Best regards,
Ilyav1: https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg01915.html
v1 -> v2: Dropmmap()in the test (Richard).Ilya Leoshkevich (3):
target/s390x: fix handling of zeroes in vfmin/vfmax target/s390x: fix NaN propagation rules tests/tcg/s390x: test signed vfmin/vfmax
Quoted 7 lines
fpu/softfloat-specialize.c.inc | 3 +- target/s390x/tcg/vec_fpu_helper.c | 4 +- tests/tcg/s390x/Makefile.target | 7 + tests/tcg/s390x/vfminmax.c | 411 ++++++++++++++++++++++++++++++ 4 files changed, 422 insertions(+), 3 deletions(-)create mode 100644
tests/tcg/s390x/vfminmax.c
Thanks, queued to my s390x-next branch now:
https://gitlab.com/thuth/qemu/-/commits/s390x-next/
Thomas