This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] PR 65315 - Fix alignment of local variables
- From: Steve Ellcey <sellcey at imgtec dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 5 Mar 2015 08:23:17 -0800
- Subject: Re: [Patch] PR 65315 - Fix alignment of local variables
- Authentication-results: sourceware.org; auth=none
- References: <2db74cc6-b63d-4f8b-aa37-525b51b0b34c at BAMAIL02 dot ba dot imgtec dot org> <CAFiYyc3PmvQL-9MrhJhv4+53vVDwOCpp=bhub-6Xb8SKq2AxKA at mail dot gmail dot com>
- Reply-to: <sellcey at imgtec dot com>
On Thu, 2015-03-05 at 09:36 +0100, Richard Biener wrote:
> >
> > I have verified the fix on the MIPS test case in PR 65315 and am doing a
> > regression test now. OK to checkin if there are no regressions?
>
> It looks like large_align vars are dynamically allocated and thus they
> should be sorted as sizeof (void *) I suppose.
>
> Do you have a testcase?
>
> Ok.
>
> Thanks,
> Richard.
>
> Richard.
Here is a test case that I used on MIPS. The 'b' and 'c' arrays both
have alignments greater than MAX_SUPPORTED_STACK_ALIGNMENT but because
'b' is larger in size than 'c' it gets sorted earlier and its alignment
is used to align the dynamically allocated memory instead of 'c' which
has a greater alignment requirement.
Steve Ellcey
sellcey@imgtec.com
int foo(int *x)
{
int i,y;
int a[40];
int b[50] __attribute__ ((aligned(32)));
int c[40] __attribute__ ((aligned(128)));
for (i = 0; i < 40; i++)
a[i] = *x++;
for (i = 0; i < 40; i++)
b[i] = *x++;
for (i = 0; i < 40; i++)
c[i] = *x++;
y = -99;
for (i = 0; i < 40; i++)
y = y + a[i] + b[i] + c[i];
return y;
}