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]

PATCH: Incorrect alignment attribute on stack parameter


locate_and_pad_parm limits parameter boundary to
PREFERRED_STACK_BOUNDARY.  But it does it
too late.
For

---
#include <stdarg.h>
#include <emmintrin.h>

int test (int a, ...);

__m128 n1 = { -283.3, -23.3, 213.4, 1119.03 };

int
foo (void)
{
  return test (1, n1);
}
---

we expand it to:

(insn 6 5 7 v.c:11 (set (mem:V4SF (plus:SI (reg/f:SI 56 virtual-outgoing-args)
                (const_int 4 [0x4])) [0 S16 A128])
        (reg:V4SF 59 [ n1.16 ])) -1 (nil))

The alignment is in correct here. As the result, the
assembly code looks like

	movaps	n1, %xmm0
	movaps	%xmm0, 4(%esp)
	movl	$1, (%esp)
	call	test

With this patch, we generate unaligned store instead:

(insn 6 5 7 v.c:11 (set (mem:V2SF (plus:SI (reg/f:SI 56 virtual-outgoing-args)
                (const_int 4 [0x4])) [0 S8 A32])
        (vec_select:V2SF (reg:V4SF 59 [ n1.19 ])
            (parallel [
                    (const_int 0 [0x0])
                    (const_int 1 [0x1])
                ]))) -1 (nil))

(insn 7 6 8 v.c:11 (set (mem:V2SF (plus:SI (reg/f:SI 56 virtual-outgoing-args)
                (const_int 12 [0xc])) [0 S8 A32])
        (vec_select:V2SF (reg:V4SF 59 [ n1.19 ])
            (parallel [
                    (const_int 2 [0x2])
                    (const_int 3 [0x3])
                ]))) -1 (nil))

OK for trunk?

Thanks.


-- 
H.J.
---
gcc/

2008-07-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/36858
	* function.c (locate_and_pad_parm): Cap boundary earlier.

testsuite/

2008-07-16  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/36858
	* gcc.target/i386/vararg-1.c: New.

Attachment: gcc-caller-1.txt
Description: Text document


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