re PR middle-end/37010 (-mno-accumulate-outgoing-args doesn't work with stack alignment)
authorH.J. Lu <hongjiu.lu@intel.com>
Wed, 6 Aug 2008 15:43:46 +0000 (15:43 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Wed, 6 Aug 2008 15:43:46 +0000 (08:43 -0700)
gcc/

2008-08-06  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/37010
* calls.c (expand_call): Use the biggest preferred stack
boundary.

gcc/testsuite/

2008-08-06  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/37010
* gcc.dg/torture/stackalign/push-1.c: New.

From-SVN: r138808

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/stackalign/push-1.c [new file with mode: 0644]

index a08bd6e6f691208b73fb26f97cd37cb49cc998d0..731839f76304d942404860b88397e5d6c3a96e84 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/37010
+       * calls.c (expand_call): Use the biggest preferred stack
+       boundary.
+
 2008-08-06  Michael Matz  <matz@suse.de>
 
        PR target/36613
index d48c0d15654bcc6c3bbe6d043775f906c2c0884d..146f251d5107453c3e7382db599785768c5244c1 100644 (file)
@@ -2319,10 +2319,13 @@ expand_call (tree exp, rtx target, int ignore)
       || !lang_hooks.decls.ok_for_sibcall (fndecl))
     try_tail_call = 0;
 
-  /* Ensure current function's preferred stack
-     boundary is at least what we need.  */
+  /* Ensure current function's preferred stack boundary is at least
+     what we need.  Stack alignment may also increase preferred stack
+     boundary.  */
   if (crtl->preferred_stack_boundary < preferred_stack_boundary)
     crtl->preferred_stack_boundary = preferred_stack_boundary;
+  else
+    preferred_stack_boundary = crtl->preferred_stack_boundary;
 
   preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
 
index d5b229a70e23f44ad7c152bd005237aae2df0b5b..a2f0d060844b4c4b3bc584ef1afef51c96b553db 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/37010
+       * gcc.dg/torture/stackalign/push-1.c: New.
+
 2008-08-06  Michael Matz  <matz@suse.de>
 
        PR target/36613
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c b/gcc/testsuite/gcc.dg/torture/stackalign/push-1.c
new file mode 100644 (file)
index 0000000..7417324
--- /dev/null
@@ -0,0 +1,59 @@
+/* PR middle-end/37010 */
+/* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-msse2 -mpreferred-stack-boundary=2" } */
+
+#include <emmintrin.h>
+#include "cpuid.h"
+
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+typedef int aligned __attribute__((aligned(16)));
+
+extern void abort (void);
+
+__m128 r;
+
+int
+__attribute__ ((noinline))
+check_int (int *i, int align)
+{
+  *i = 20;
+  if ((((ptrdiff_t) i) & (align - 1)) != 0)
+    {
+      abort ();
+    }
+  return *i;
+}
+
+void
+__attribute__ ((noinline))
+foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size)
+{
+  aligned i;
+
+  if (size != 5 || check_int (&i, __alignof__(i)) != i)
+    abort ();
+
+  r = a;
+}
+
+int
+main (void)
+{
+  __m128 x = { 1.0 };
+  unsigned int eax, ebx, ecx, edx;
+  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
+    return 0;
+
+  /* Run SSE2 test only if host has SSE2 support.  */
+  if (edx & bit_SSE2)
+    {
+      foo (x, x, x, x, 5);
+
+      if (__builtin_memcmp (&r, &x, sizeof (r)))
+       abort ();
+    }
+
+  return 0;
+}