[hjl@gnu-6 pr]$ cat x.c typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__)); extern void bar (__m128 *); void foo (__m128 *x) { __m128 b = *x; bar (&b); } [hjl@gnu-6 pr]$ make x.s /export/build/gnu/gcc-work/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-work/build-x86_64-linux/gcc/ -S -o x.s -O2 -fno-asynchronous-unwind-tables x.c [hjl@gnu-6 pr]$ cat x.s .file "x.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: subq $24, %rsp movaps (%rdi), %xmm0 movq %rsp, %rdi movlps %xmm0, (%rsp) movhps %xmm0, 8(%rsp) call bar addq $24, %rsp ret expand_one_stack_var_at has /* Set alignment we actually gave this decl. */ offset -= frame_phase; align = offset & -offset; align *= BITS_PER_UNIT; if (align > STACK_BOUNDARY || align == 0) align = STACK_BOUNDARY; DECL_ALIGN (decl) = align; DECL_USER_ALIGN (decl) = 0; set_mem_attributes (x, decl, true); That is we always set alignment attribute of a stack variable to <= STACK_BOUNDARY even if we can align it properly. One consequence is unaligned move is used on aligned memory.
Gcc 4.3 generates aligned move since it doesn't check the alignment attribute.
Created attachment 17368 [details] A patch Does this patch make sense?
(In reply to comment #2) > Created an attachment (id=17368) [edit] > A patch > Does this patch make sense? It works fine.
(In reply to comment #3) > (In reply to comment #2) > > Created an attachment (id=17368) [edit] > > A patch > > Does this patch make sense? > It works fine. > It failed for me in libgcc during bootstrap on Linux/ia32.
Created attachment 17373 [details] A new patch This patch may work better.
Created attachment 17375 [details] An updated patch When align == 0, we should align variable to STACK_BOUNDARY.
A patch is posted at http://gcc.gnu.org/ml/gcc-patches/2009-02/msg01267.html
Subject: Bug 39315 Author: hjl Date: Sat Feb 28 18:55:06 2009 New Revision: 144492 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144492 Log: gcc/ 2009-02-28 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-02-28 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. Added: branches/stack/gcc/testsuite/gcc.target/i386/pr39315-1.c branches/stack/gcc/testsuite/gcc.target/i386/pr39315-2.c branches/stack/gcc/testsuite/gcc.target/i386/pr39315-3.c branches/stack/gcc/testsuite/gcc.target/i386/pr39315-4.c branches/stack/gcc/testsuite/gcc.target/i386/pr39315-check.c Modified: branches/stack/gcc/ChangeLog.stackalign branches/stack/gcc/cfgexpand.c branches/stack/gcc/testsuite/ChangeLog.stackalign
Subject: Bug 39315 Author: hjl Date: Fri Mar 27 22:37:39 2009 New Revision: 145138 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145138 Log: 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. Added: trunk/gcc/testsuite/gcc.target/i386/pr39315-1.c trunk/gcc/testsuite/gcc.target/i386/pr39315-2.c trunk/gcc/testsuite/gcc.target/i386/pr39315-3.c trunk/gcc/testsuite/gcc.target/i386/pr39315-4.c trunk/gcc/testsuite/gcc.target/i386/pr39315-check.c Modified: trunk/gcc/ChangeLog trunk/gcc/cfgexpand.c trunk/gcc/testsuite/ChangeLog
Stop setting the target milestone unless it is a regression.
*** Bug 40838 has been marked as a duplicate of this bug. ***
Subject: Bug 39315 Author: hjl Date: Sat Oct 31 16:58:17 2009 New Revision: 153780 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153780 Log: gcc/ 2009-10-31 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline: 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-10-31 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline: 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. Added: branches/ix86/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr39315-1.c branches/ix86/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr39315-2.c branches/ix86/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr39315-3.c branches/ix86/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr39315-4.c branches/ix86/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr39315-check.c Modified: branches/ix86/gcc-4_4-branch/gcc/ChangeLog.ix86 branches/ix86/gcc-4_4-branch/gcc/cfgexpand.c branches/ix86/gcc-4_4-branch/gcc/testsuite/ChangeLog.ix86
*** Bug 43124 has been marked as a duplicate of this bug. ***
On trunk I get: foo: subl $44, %esp movl 48(%esp), %eax movaps (%eax), %xmm0 leal 16(%esp), %eax movl %eax, (%esp) movaps %xmm0, 16(%esp) call bar addl $44, %esp ret thus, fixed.