[PATCH] libffi: fix handling of homogeneous float128 structs [PR109447]

Peter Bergner bergner@linux.ibm.com
Thu May 4 19:29:34 GMT 2023


I'd like to pull in Dan's upstream libffi commit into trunk to fix a
wrong code bug/testsuite failure on powerpc64le-linux with long double
defaulting to ieee128.  This passed bootstrap and regtesting with no
regressions.  Ok for trunk?

This bug is also on the GCC 12 and GCC 11 release branches. Ok there too
assuming testing is clean?  I can wait to push the gcc12 backport until
after the release.

Peter


If there is a homogeneous struct with float128 members, they should be
copied to vector register save area. The current code incorrectly copies
only the value of the first member, not increasing the pointer with each
iteration. Fix this.

Merged from upstream libffi commit: 464b4b66e3cf3b5489e730c1466ee1bf825560e0

2023-05-03  Dan Horák <dan@danny.cz>

libffi/
	PR libffi/109447
	* src/powerpc/ffi_linux64.c (ffi_prep_args64): Update arg.f128 pointer.

diff --git a/libffi/src/powerpc/ffi_linux64.c b/libffi/src/powerpc/ffi_linux64.c
index 4d50878e402..3454dacd3d6 100644
--- a/libffi/src/powerpc/ffi_linux64.c
+++ b/libffi/src/powerpc/ffi_linux64.c
@@ -680,7 +680,7 @@ ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
                     {
                       if (vecarg_count < NUM_VEC_ARG_REGISTERS64
                           && i < nfixedargs)
-		        memcpy (vec_base.f128++, arg.f128, sizeof (float128));
+		        memcpy (vec_base.f128++, arg.f128++, sizeof (float128));
                       else
 		        memcpy (next_arg.f128, arg.f128++, sizeof (float128));
                       if (++next_arg.f128 == gpr_end.f128)



More information about the Gcc-patches mailing list