re PR middle-end/39315 (Unaligned move used on aligned stack variable)

gcc/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/39315
	* cfgexpand.c (expand_one_stack_var_at): Change alignment
	limit to MAX_SUPPORTED_STACK_ALIGNMENT.

gcc/testsuite/

2009-03-27  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/39315
	* gcc.target/i386/pr39315-1.c: New.
	* gcc.target/i386/pr39315-2.c: Likewise.
	* gcc.target/i386/pr39315-3.c: Likewise.
	* gcc.target/i386/pr39315-4.c: Likewise.
	* gcc.target/i386/pr39315-check.c: Likewise.

From-SVN: r145138
This commit is contained in:
H.J. Lu 2009-03-27 22:37:39 +00:00 committed by H.J. Lu
parent 472c7fbd09
commit 2ac26e152e
8 changed files with 109 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2009-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/39315
* cfgexpand.c (expand_one_stack_var_at): Change alignment
limit to MAX_SUPPORTED_STACK_ALIGNMENT.
2009-03-27 Richard Guenther <rguenther@suse.de>
PR tree-optimization/39120

View file

@ -866,7 +866,8 @@ dump_stack_var_partition (void)
static void
expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset)
{
HOST_WIDE_INT align;
/* Alignment is unsigned. */
unsigned HOST_WIDE_INT align;
rtx x;
/* If this fails, we've overflowed the stack frame. Error nicely? */
@ -879,8 +880,10 @@ expand_one_stack_var_at (tree decl, HOST_WIDE_INT offset)
offset -= frame_phase;
align = offset & -offset;
align *= BITS_PER_UNIT;
if (align > STACK_BOUNDARY || align == 0)
if (align == 0)
align = STACK_BOUNDARY;
else if (align > MAX_SUPPORTED_STACK_ALIGNMENT)
align = MAX_SUPPORTED_STACK_ALIGNMENT;
DECL_ALIGN (decl) = align;
DECL_USER_ALIGN (decl) = 0;

View file

@ -8,6 +8,15 @@
PR tree-optimization/39120
* gcc.dg/torture/pta-callused-1.c: New testcase.
2009-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/39315
* gcc.target/i386/pr39315-1.c: New.
* gcc.target/i386/pr39315-2.c: Likewise.
* gcc.target/i386/pr39315-3.c: Likewise.
* gcc.target/i386/pr39315-4.c: Likewise.
* gcc.target/i386/pr39315-check.c: Likewise.
2009-03-27 H.J. Lu <hongjiu.lu@intel.com>
PR c/39323

View file

@ -0,0 +1,18 @@
/* PR middle-end/39315 */
/* { dg-do compile } */
/* { dg-options "-O -msse2 -mtune=generic" } */
/* { dg-final { scan-assembler-not "movups" } } */
/* { dg-final { scan-assembler-not "movlps" } } */
/* { dg-final { scan-assembler-not "movhps" } } */
/* { dg-final { scan-assembler "movaps" } } */
typedef float __m128 __attribute__ ((__vector_size__ (16)));
extern void bar (__m128 *);
void
foo (__m128 *x)
{
__m128 b = *x;
bar (&b);
}

View file

@ -0,0 +1,15 @@
/* PR middle-end/39315 */
/* { dg-do run } */
/* { dg-options "-O -msse2 -mtune=generic" } */
/* { dg-additional-sources pr39315-check.c } */
typedef float __m128 __attribute__ ((__vector_size__ (16)));
extern void bar (__m128 *, int);
void
foo (__m128 *x)
{
__m128 b = *x;
bar (&b, __alignof__ (x));
}

View file

@ -0,0 +1,19 @@
/* PR middle-end/39315 */
/* { dg-do compile } */
/* { dg-options "-O -msse2 -mtune=generic" } */
/* { dg-final { scan-assembler-not "movups" } } */
/* { dg-final { scan-assembler-not "movlps" } } */
/* { dg-final { scan-assembler-not "movhps" } } */
/* { dg-final { scan-assembler "and\[lq\]?\[\\t \]*\\$-128,\[\\t \]*%\[re\]?sp" } } */
/* { dg-final { scan-assembler "movaps" } } */
typedef float __m128 __attribute__ ((__vector_size__ (16)));
extern void bar (__m128 *);
void
foo (__m128 *x)
{
__m128 b __attribute__ ((aligned(128))) = *x;
bar (&b);
}

View file

@ -0,0 +1,15 @@
/* PR middle-end/39315 */
/* { dg-do run } */
/* { dg-options "-O -msse2 -mtune=generic" } */
/* { dg-additional-sources pr39315-check.c } */
typedef float __m128 __attribute__ ((__vector_size__ (16)));
extern void bar (__m128 *, int);
void
foo (__m128 *x)
{
__m128 b __attribute__ ((aligned(128))) = *x;
bar (&b, __alignof__ (x));
}

View file

@ -0,0 +1,22 @@
typedef float __m128 __attribute__ ((__vector_size__ (16)));
extern void foo (__m128 *);
extern void abort (void);
__m128 y = { 0.0, 1.0, 2.0, 3.0 };
void
bar (__m128 *x, int align)
{
if ((((__PTRDIFF_TYPE__) x) & (align - 1)) != 0)
abort ();
if (__builtin_memcmp (x, &y, sizeof (y)) != 0)
abort ();
}
int
main ()
{
foo (&y);
return 0;
}