This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] MIPS: Align local variables like global variables
- From: Richard Sandiford <rsandifo at nildram dot co dot uk>
- To: Nigel Stephens <nigel at mips dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 26 Sep 2007 17:53:26 +0100
- Subject: Re: [Patch] MIPS: Align local variables like global variables
- References: <18170.21228.562452.609229@southgate.mips.com>
Nigel Stephens <nigel@mips.com> writes:
> +/* If defined, a C expression to compute the alignment for a local
> + variable. TYPE is the data type, and ALIGN is the alignment that
> + the object would ordinarily have. The value of this macro is used
> + instead of that alignment to align the object.
>
> + If this macro is not defined, then ALIGN is used.
> +
> + One use of this macro is to increase alignment of medium-size data
> + to make it all fit in fewer cache lines. We need this for the same
> + reason as DATA_ALIGNMENT, namely to cause character arrays to be
> + word-aligned so that `strcpy' calls that copy constants to
> + character arrays can be done inline, and 'strcmp' can be optimised
> + to use word loads. */
> +
> +#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
> + DATA_ALIGNMENT(TYPE, ALIGN)
Nits first: please drop the boiler-plate stuff, i.e. everything up to
"fewer cache lines." (I know there are lots of pre-existing examples,
but I'm hoping to make a sweep over them before 4.3.) Missing space
in "DATA_ALIGNMENT(".
More importantly, is this a win even for -Os? Unlike DATA_ALIGNMENT[*],
this should be purely a tuning decision, so can depend on things like
optimize_size.
[*] ISTR MIPSpro expected global variables to have the alignment
specified by DATA_ALIGNMENT, even if gcc doesn't.
Richard
PS. For the sake of ceremony, please remember to say how patches
were tested ;)