This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] PR 65315 - Fix alignment of local variables


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;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]