diff mbox series

[1/2] bitint: Use TARGET_ARRAY_MODE for large bitints where target supports it

Message ID 20240125174501.32634-2-andre.simoesdiasvieira@arm.com
State New
Headers show
Series aarch64, bitint: Add support for _BitInt for AArch64 Little Endian | expand

Commit Message

Andre Vieira (lists) Jan. 25, 2024, 5:45 p.m. UTC
This patch ensures we use TARGET_ARRAY_MODE to determine the storage mode of
large bitints that are represented as arrays in memory.  This is required to
support such bitints for aarch64 and potential other targets with similar
bitint specifications.  Existing tests like gcc.dg/torture/bitint-25.c are
affected by this for aarch64 targets.

gcc/ChangeLog:
	stor-layout.cc (layout_type): Use TARGET_ARRAY_MODE for large bitints
	for targets that implement it.
---
 gcc/stor-layout.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Jakub Jelinek Feb. 2, 2024, 3:18 p.m. UTC | #1
On Thu, Jan 25, 2024 at 05:45:00PM +0000, Andre Vieira wrote:
> 
> This patch ensures we use TARGET_ARRAY_MODE to determine the storage mode of
> large bitints that are represented as arrays in memory.  This is required to
> support such bitints for aarch64 and potential other targets with similar
> bitint specifications.  Existing tests like gcc.dg/torture/bitint-25.c are
> affected by this for aarch64 targets.
> 
> gcc/ChangeLog:
> 	stor-layout.cc (layout_type): Use TARGET_ARRAY_MODE for large bitints
> 	for targets that implement it.

I thought this has been resolved by the r14-8275 change.
Do you really need it for something?
I've tried
make check-gcc -j32 -k GCC_TEST_RUN_EXPENSIVE=1 RUNTESTFLAGS="GCC_TEST_RUN_EXPENSIVE=1 dg.exp='*bitint* pr112673.c builtin-stdc-bit-*.c pr112566-2.c pr112511.c' dg-torture.exp=*bitint* dfp.exp=*bitint*"
in a x86_64 -> aarch64-linux cross with your other patch but not this one
and didn't see any ICEs (note, as I didn't have any aarch64 libc around,
all tests fail during linking).

I think BITINT_TYPE mode really should be that of a struct containing that
many limb elements rather than of an array and this patch doesn't match
that.

> diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc
> index 4cf249133e9..31da2c123ab 100644
> --- a/gcc/stor-layout.cc
> +++ b/gcc/stor-layout.cc
> @@ -2427,8 +2427,16 @@ layout_type (tree type)
>  	  }
>  	else
>  	  {
> -	    SET_TYPE_MODE (type, BLKmode);
>  	    cnt = CEIL (TYPE_PRECISION (type), GET_MODE_PRECISION (limb_mode));
> +	    machine_mode mode;
> +	    /* Some targets use TARGET_ARRAY_MODE to select the mode they use
> +	       for arrays with a specific element mode and a specific element
> +	       count and we should use this mode for large bitints that are
> +	       stored as such arrays.  */
> +	    if (!targetm.array_mode (limb_mode, cnt).exists (&mode)
> +		|| !targetm.array_mode_supported_p (limb_mode, cnt))
> +	      mode = BLKmode;
> +	    SET_TYPE_MODE (type, mode);
>  	    gcc_assert (info.abi_limb_mode == info.limb_mode
>  			|| !info.big_endian == !WORDS_BIG_ENDIAN);
>  	  }


	Jakub
diff mbox series

Patch

diff --git a/gcc/stor-layout.cc b/gcc/stor-layout.cc
index 4cf249133e9..31da2c123ab 100644
--- a/gcc/stor-layout.cc
+++ b/gcc/stor-layout.cc
@@ -2427,8 +2427,16 @@  layout_type (tree type)
 	  }
 	else
 	  {
-	    SET_TYPE_MODE (type, BLKmode);
 	    cnt = CEIL (TYPE_PRECISION (type), GET_MODE_PRECISION (limb_mode));
+	    machine_mode mode;
+	    /* Some targets use TARGET_ARRAY_MODE to select the mode they use
+	       for arrays with a specific element mode and a specific element
+	       count and we should use this mode for large bitints that are
+	       stored as such arrays.  */
+	    if (!targetm.array_mode (limb_mode, cnt).exists (&mode)
+		|| !targetm.array_mode_supported_p (limb_mode, cnt))
+	      mode = BLKmode;
+	    SET_TYPE_MODE (type, mode);
 	    gcc_assert (info.abi_limb_mode == info.limb_mode
 			|| !info.big_endian == !WORDS_BIG_ENDIAN);
 	  }