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. 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])) { #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]); #else @@ -238,12 +252,12 @@ main() conv_result.d = conv_fp128_2_i128 (conv.e); - 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_fp128_2_i128(0x%llx %llx) = ", - conv.uint128[1], conv.uint128[0]); - printf("0x%llx %llx\n", conv_result.uint128[1], conv_result.uint128[0]); + conv.uint128[MSW], conv.uint128[LSW]); + printf("0x%llx %llx\n", conv_result.uint128[MSW], conv_result.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]); @@ -257,12 +271,12 @@ main() expected_result_uint128[0] = 0xffffffffffffe57b; conv_result.d = conv_fp128_2_i128 (conv.e); - 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_fp128_2_i128(0x%llx %llx) = ", - conv.uint128[1], conv.uint128[0]); - printf("0x%llx %llx\n", conv_result.uint128[1], conv_result.uint128[0]); + conv.uint128[MSW], conv.uint128[LSW]); + printf("0x%llx %llx\n", conv_result.uint128[MSW], conv_result.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]); @@ -276,12 +290,12 @@ main() expected_result_uint128[0] = 0x1a85; conv_result.d = conv_fp128_2_ui128 (conv.e); - 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_fp128_2_ui128(0x%llx %llx) = ", - conv.uint128[1], conv.uint128[0]); - printf("0x%llx %llx\n", conv_result.uint128[1], conv_result.uint128[0]); + conv.uint128[MSW], conv.uint128[LSW]); + printf("0x%llx %llx\n", conv_result.uint128[MSW], conv_result.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]); diff --git a/gcc/testsuite/gcc.target/powerpc/int_128bit-runnable.c b/gcc/testsuite/gcc.target/powerpc/int_128bit-runnable.c index 756142d1bc6..e902aa59c37 100644 --- a/gcc/testsuite/gcc.target/powerpc/int_128bit-runnable.c +++ b/gcc/testsuite/gcc.target/powerpc/int_128bit-runnable.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-options "-mdejagnu-cpu=power10 -save-temps" } */ +/* { dg-require-effective-target int128 } */ /* { dg-require-effective-target power10_hw } */ /* Check that the expected 128-bit instructions are generated if the processor -- 2.52.0
