On 25/08/26 1:05 pm, Manjunath S Matti wrote:
> The test inspects the 128-bit conversion results through a union of
> two 64-bit halves, and assumes throughout that element [1] holds the
> most significant half and element [0] the least significant one. That
> is only true on little endian: __float128 and __int128_t are single
> 128-bit scalars, so which array element holds the most significant
> half depends on the target endianness.
>
> Add MSW/LSW macros for the two halves and use them when reading the
> union.
>
> Add the missing int128 effective-target requirement, so the -m32 variant
> now reports UNSUPPORTED instead of FAIL.
>
> Tested on powerpc64-linux-gnu and powerpc64le-linux-gnu.
>
> 2026-08-24 Manjunath Matti <[email protected]>
>
> gcc/testsuite/
> * gcc.target/powerpc/fp128_conversions.c: New macros
> defined, use them when reading the union.
> * gcc.target/powerpc/int_128bit-runnable.c: Require
> int128 effective target.
>
Can you please add PR target/125966 to the gcc/testsuite/ChangeLog entry?
> diff --git a/gcc/testsuite/gcc.target/powerpc/fp128_conversions.c
> b/gcc/testsuite/gcc.target/powerpc/fp128_conversions.c
> index c20282fa0e0..2f6a7d67309 100644
> --- a/gcc/testsuite/gcc.target/powerpc/fp128_conversions.c
> +++ b/gcc/testsuite/gcc.target/powerpc/fp128_conversions.c
> @@ -1,5 +1,6 @@
> /* { dg-do run } */
> /* { dg-require-effective-target power10_hw } */
> +/* { dg-require-effective-target int128 } */
> /* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */
>
> /* Check that the expected 128-bit instructions are generated if the
> processor
> @@ -17,6 +18,19 @@
>
> #define DEBUG 0
>
> +/* The union below views a 128-bit value as two 64-bit halves. __float128
> + and __int128_t are single 128-bit scalars, so which array element holds
> + the most significant half depends on endianness. (__ibm128 / long double
> + is a pair of doubles stored high-order first on both endians, so the
> + long double check below deliberately keeps the plain indices.) */
> +#ifdef __BIG_ENDIAN__
> +#define MSW 0
> +#define LSW 1
> +#else
> +#define MSW 1
> +#define LSW 0
> +#endif
> +
> void
> abort (void);
>
> @@ -166,11 +180,11 @@ main()
> expected_result_uint128[1] = 0xc02bd2f9068d1160;
> expected_result_uint128[0] = 0x0;
>
> - if ((conv_result.uint128[1] != expected_result_uint128[1])
> - && (conv_result.uint128[0] != expected_result_uint128[0])) {
> + if ((conv_result.uint128[MSW] != expected_result_uint128[1])
> + && (conv_result.uint128[LSW] != expected_result_uint128[0])) {
> #if DEBUG
> printf("ERROR: conv_i128_2_fp128(-32109876543210) = (result in hex)
> 0x%llx %llx\n",
> - conv.uint128[1], conv.uint128[0]);
> + conv.uint128[MSW], conv.uint128[LSW]);
> printf("\n does not match expected_result = (result in hex) 0x%llx
> %llx\n\n",
> expected_result_uint128[1],
> expected_result_uint128[0]);
> #else
> @@ -202,11 +216,11 @@ main()
> expected_result_uint128[1] = 0x402d3eb101df8b48;
> expected_result_uint128[0] = 0x0;
>
> - if ((conv_result.uint128[1] != expected_result_uint128[1])
> - && (conv_result.uint128[0] != expected_result_uint128[0])) {
> + if ((conv_result.uint128[MSW] != expected_result_uint128[1])
> + && (conv_result.uint128[LSW] != expected_result_uint128[0])) {
>
The failure check uses && [(a != x) && (b != y)], so it only flags a mismatch
when both halves are wrong,
if just one 64-bit half gets corrupted, the test silently passes.
Though this change wasn't made by you, just pointing out here.
Thanks,
Jeevitha.
#if DEBUG
> printf("ERROR: conv_ui128_2_fp128(87601234567890) = (result in hex)
> 0x%llx %llx\n",
> - conv.uint128[1], conv.uint128[0]);
> + conv.uint128[MSW], conv.uint128[LSW]);
> printf("\n does not match expected_result = (result in hex) 0x%llx
> %llx\n\n",
> expected_result_uint128[1],
> expected_result_uint128[0]);
> #else
> @@ -220,11 +234,11 @@ main()
> expected_result_uint128[0] = 0x0;
> conv_result.e = conv_ui128_2_fp128 (u128);
>
> - if ((conv_result.uint128[1] != expected_result_uint128[1])
> - && (conv_result.uint128[0] != expected_result_uint128[0])) {
> + if ((conv_result.uint128[MSW] != expected_result_uint128[1])
> + && (conv_result.uint128[LSW] != expected_result_uint128[0])) {
> #if DEBUG
> printf("ERROR: conv_ui128_2_fp128(32109876543210) = (result in hex)
> 0x%llx %llx\n",
> - conv.uint128[1], conv.uint128[0]);
> + conv.uint128[MSW], conv.uint128[LSW]);
> printf("\n does not match expected_result = (result in hex) 0x%llx
> %llx\n\n",
> expected_result_uint128[1],
> expected_result_uint128[0]);
>