The default value of MAX_BITSIZE_MODE_ANY_MODE is calculated from the initial mode sizes specified in the modes.def file. The target needs to be able to override it if ADJUST_BYTESIZE & co. can choose a bigger size.
Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by comparing the before and after assembly output for at least one target per CPU directory. Applied (as a gen* patch). Richard 2018-01-03 Richard Sandiford <richard.sandif...@linaro.org> gcc/ * doc/rtl.texi (MAX_BITSIZE_MODE_ANY_MODE): Describe how the default is calculated and how it can be overridden. * genmodes.c (max_bitsize_mode_any_mode): New variable. (create_modes): Initialize it from MAX_BITSIZE_MODE_ANY_MODE, if defined. (emit_max_int): Use it to set the output MAX_BITSIZE_MODE_ANY_MODE, if nonzero. Index: gcc/doc/rtl.texi =================================================================== --- gcc/doc/rtl.texi 2018-01-03 09:44:10.691921247 +0000 +++ gcc/doc/rtl.texi 2018-01-03 09:44:10.854914708 +0000 @@ -1509,7 +1509,12 @@ compute integer values. @findex MAX_BITSIZE_MODE_ANY_MODE @item MAX_BITSIZE_MODE_ANY_MODE -The bitsize of the largest mode on the target. +The bitsize of the largest mode on the target. The default value is +the largest mode size given in the mode definition file, which is +always correct for targets whose modes have a fixed size. Targets +that might increase the size of a mode beyond this default should define +@code{MAX_BITSIZE_MODE_ANY_MODE} to the actual upper limit in +@file{@var{machine}-modes.def}. @end table @findex byte_mode Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2018-01-03 09:44:10.691921247 +0000 +++ gcc/genmodes.c 2018-01-03 09:44:10.854914708 +0000 @@ -792,6 +792,7 @@ #define ADJUST_FBIT(M, X) _ADD_ADJUST ( static int bits_per_unit; static int max_bitsize_mode_any_int; +static int max_bitsize_mode_any_mode; static void create_modes (void) @@ -811,6 +812,12 @@ create_modes (void) #else max_bitsize_mode_any_int = 0; #endif + +#ifdef MAX_BITSIZE_MODE_ANY_MODE + max_bitsize_mode_any_mode = MAX_BITSIZE_MODE_ANY_MODE; +#else + max_bitsize_mode_any_mode = 0; +#endif } #ifndef NUM_POLY_INT_COEFFS @@ -989,12 +996,18 @@ emit_max_int (void) else printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int); - mmax = 0; - for (j = 0; j < MAX_MODE_CLASS; j++) - for (i = modes[j]; i; i = i->next) - if (mmax < i->bytesize) - mmax = i->bytesize; - printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax); + if (max_bitsize_mode_any_mode == 0) + { + mmax = 0; + for (j = 0; j < MAX_MODE_CLASS; j++) + for (i = modes[j]; i; i = i->next) + if (mmax < i->bytesize) + mmax = i->bytesize; + printf ("#define MAX_BITSIZE_MODE_ANY_MODE (%d*BITS_PER_UNIT)\n", mmax); + } + else + printf ("#define MAX_BITSIZE_MODE_ANY_MODE %d\n", + max_bitsize_mode_any_mode); } /* Emit mode_size_inline routine into insn-modes.h header. */