This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/37010] -Os passes __m128 on stack with wrong alignment
- From: "hjl dot tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Aug 2008 20:11:20 -0000
- Subject: [Bug target/37010] -Os passes __m128 on stack with wrong alignment
- References: <bug-37010-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from hjl dot tools at gmail dot com 2008-08-03 20:11 -------
A run-time testcase:
bash-3.2$ cat y.c
/* PR middle-end/37010 */
/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
/* { dg-options "-msse2" } */
typedef __PTRDIFF_TYPE__ ptrdiff_t;
extern void abort (void);
int
__attribute__ ((noinline))
check_int (int *i, int align)
{
*i = 20;
if ((((ptrdiff_t) i) & (align - 1)) != 0)
{
abort ();
}
return *i;
}
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
typedef int aligned __attribute__((aligned(16)));
__m128 r;
void
__attribute__ ((noinline))
foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
{
aligned i;
if (check_int (&i, __alignof__(i)) != i)
abort ();
r = a;
}
int
main (void)
{
__m128 x = { 1.0 };
foo (x, x, x, x, 5);
if (__builtin_memcmp (&r, &x, sizeof (r)))
abort ();
return 0;
}
bash-3.2$ make y
/export/build/gnu/gcc-avx/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-avx/build-x86_64-linux/gcc/ -m32 -msse2 -DDEBUG -Os
-mpreferred-stack-boundary=2 y.c -o y
bash-3.2$ ./y
Segmentation fault
bash-3.2$ /export/build/gnu/gcc-avx/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-avx/build-x86_64-linux/gcc/ -m32 -msse2 -DDEBUG -O
-mpreferred-stack-boundary=2 y.c -o y
bash-3.2$ ./y
bash-3.2$
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37010