Hans-Peter Nilsson <h...@bitrange.com> writes:
> On Fri, 18 Jul 2025, Pietro Monteiro wrote:
>> I think you need to update the description of MAX_FIXED_MODE_SIZE in
>> gcc/doc/tm.texi.in with the new default.
>
> Oops, absolutely, thanks for pointing that out.
>
> Here's v2, with info and dvi results inspected for sanity.
>
> Ok to commit now?  (Note: scissors marking in effect.)
>
> From: Hans-Peter Nilsson <h...@bitrange.com>
>
> This has an effect only for MMIX and BPF.  All other targets are
> either 32-bits-or-less BITS_PER_WORD (and will now get 64 just
> by a more obvious expression), or they don't use the default
> MAX_FIXED_MODE_SIZE.
>
> I can't build a complete toolchain for BPF (fails building
> libgcc, PR121149), but from what I can see with that build,
> having MAX_FIXED_MODE_SIZE 64 is unintended: TImode isn't
> disabled for BPF.  So, I'm not offering a patch to keep
> MAX_FIXED_MODE_SIZE 64 for BPF; with this patch, it moves to 2 *
> BITS_PER_WORD == 128 as all other 64-bitters.

There's a risk that changing MAX_FIXED_MODE_SIZE could change the ABI,
if the ABI routines aren't sufficiently robust against mode choices
for parameter and return types.  Proving that that isn't a problem seems
harder than providing the override.  So personally I'd be happier with
adding the BPF definition.

I did wonder whether the other limit should be 8 * BITS_PER_UNIT rather
than 64, since DImode would be a 128-bit mode for a 16 bits-per-byte target.
That seems unlikely to be what such a target would want, though, so I agree
64 is better.

OK from my POV with the BPF override, but perhaps others are braver and
are happy with it as-is.

Thanks,
Richard

>
> (BTW, disabling TImode and building an unmodified libgcc for a
> target with MIN_UNITS_PER_WORD > 4 is not currently possible.)
>
> Tested cris-elf (using the "new" default) and MMIX (fixing
> gcc.dg/pr105094.c and incidentally PR 120935, where there's a
> more proper patch proposed) and native x86_64 (though it doesn't
> use the default at all).
>
> -- >8 --
> The old GET_MODE_SIZE (DImode) (i.e. 64) made sense before
> 64-bitters.  Now the default is just a trap: when using the
> default 64, things like TImode (128 bits) still mostly works,
> but general corner cases related to computing large-size objects
> numbers, like (1 << 64)/8 break, as exposed by
> gcc.dg/pr105094.c.
>
> So, keep the floor at 64 for 32-bitters and smaller targets, but
> for larger targets, make it 2 * BITS_PER_WORD.  Also, express it
> more directly with focus on BITS_PER_WORD, not the size of a
> mode.  Add "by GCC internally" in an attempt to tell that this
> is when gcc cooks something up, not when plain input uses a type
> with such a mode.
>
>       * defaults.h (MAX_FIXED_MODE_SIZE): Default to 2 * BITS_PER_WORD
>       for larger-than-32-bitters.
>       * doc/tm.texi.in (MAX_FIXED_MODE_SIZE): Adjust accordingly.  Tweak
>       wording.
>       * doc/tm.texi: Regenerate.
> ---
>  gcc/defaults.h     | 2 +-
>  gcc/doc/tm.texi    | 8 ++++----
>  gcc/doc/tm.texi.in | 8 ++++----
>  3 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/defaults.h b/gcc/defaults.h
> index 16f6dc24e3b8..f807ef667e6d 100644
> --- a/gcc/defaults.h
> +++ b/gcc/defaults.h
> @@ -1158,7 +1158,7 @@ see the files COPYING3 and COPYING.RUNTIME 
> respectively.  If not, see
>  #endif
>  
>  #ifndef MAX_FIXED_MODE_SIZE
> -#define MAX_FIXED_MODE_SIZE GET_MODE_BITSIZE (DImode)
> +#define MAX_FIXED_MODE_SIZE MAX (BITS_PER_WORD * 2, 64)
>  #endif
>  
>  /* Nonzero if structures and unions should be returned in memory.
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index 5e305643b3a0..9a22acc0dba6 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -1424,10 +1424,10 @@ the smaller of @var{computed} and 
> @code{BIGGEST_ALIGNMENT}
>  
>  @defmac MAX_FIXED_MODE_SIZE
>  An integer expression for the size in bits of the largest integer
> -machine mode that should actually be used.  All integer machine modes of
> -this size or smaller can be used for structures and unions with the
> -appropriate sizes.  If this macro is undefined, @code{GET_MODE_BITSIZE
> -(DImode)} is assumed.
> +machine mode that should actually be used by GCC internally.
> +All integer machine modes of this size or smaller can be used for
> +structures and unions with the appropriate sizes.  If this macro is
> +undefined, @code{MAX (BITS_PER_WORD * 2, 64)} is assumed.
>  @end defmac
>  
>  @defmac STACK_SAVEAREA_MODE (@var{save_level})
> diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
> index eccc4d884938..063751120fe1 100644
> --- a/gcc/doc/tm.texi.in
> +++ b/gcc/doc/tm.texi.in
> @@ -1251,10 +1251,10 @@ the smaller of @var{computed} and 
> @code{BIGGEST_ALIGNMENT}
>  
>  @defmac MAX_FIXED_MODE_SIZE
>  An integer expression for the size in bits of the largest integer
> -machine mode that should actually be used.  All integer machine modes of
> -this size or smaller can be used for structures and unions with the
> -appropriate sizes.  If this macro is undefined, @code{GET_MODE_BITSIZE
> -(DImode)} is assumed.
> +machine mode that should actually be used by GCC internally.
> +All integer machine modes of this size or smaller can be used for
> +structures and unions with the appropriate sizes.  If this macro is
> +undefined, @code{MAX (BITS_PER_WORD * 2, 64)} is assumed.
>  @end defmac
>  
>  @defmac STACK_SAVEAREA_MODE (@var{save_level})

Reply via email to