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]

fix middle-end/17930


This PR demonstrates that we were incorrectly computing the alignment
that a local function wanted to receive.

For cfun->stack_alignment_needed we compute the alignment of cfun's
local stack frame.  For preferred_stack_boundary we compute the max
alignment of any function called by cfun.  These two numbers affect
the layout of cfun's local stack frame in different ways.  In
particular, stack_alignment_needed controls the amount of padding
at the top of the frame, and preferred_stack_boundary the amount of
padding at the bottom of the frame.

The two numbers are not interchangable at all.  And recursiveness
has nothing to do with the amount of alignment required to satisfy
either requirement.

The test case is a bit touchy.  We need to force the use of pushes
instead of moves in order to see the bad computation.  This combination
of options happens to users when the compiler is configured as i386
and they use -msse2 instead of -march=pentium4.

Tested on i686-linux.


r~


        * passes.c (rest_of_clean_state): Fix computation of
        preferred_incoming_stack_boundary.

Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.59
diff -c -p -d -u -r2.59 passes.c
--- passes.c	30 Nov 2004 12:10:23 -0000	2.59
+++ passes.c	14 Dec 2004 01:29:07 -0000
@@ -1503,8 +1503,7 @@ rest_of_clean_state (void)
   if (targetm.binds_local_p (current_function_decl))
     {
       int pref = cfun->preferred_stack_boundary;
-      if (cfun->recursive_call_emit
-          && cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
+      if (cfun->stack_alignment_needed > cfun->preferred_stack_boundary)
 	pref = cfun->stack_alignment_needed;
       cgraph_rtl_info (current_function_decl)->preferred_incoming_stack_boundary
         = pref;
Index: testsuite/gcc.dg/i386-sse-10.c
===================================================================
RCS file: testsuite/gcc.dg/i386-sse-10.c
diff -N testsuite/gcc.dg/i386-sse-10.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/i386-sse-10.c	14 Dec 2004 01:29:07 -0000
@@ -0,0 +1,34 @@
+/* PR 17930 */
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O1 -msse2 -mfpmode=sse -mno-accumulate-outgoing-args" } */
+
+#include "i386-cpuid.h"
+
+typedef _Complex double complex_16;
+
+void NOINLINE
+test (complex_16 a[5][5])
+{
+  int i, j, k;
+  complex_16 x;
+
+  for (j = 0; j < 5; j++)
+    for (i = 0; i < 5; i++)
+      {
+        for (k = 0; k < j - 1; ++k)
+	  x = a[k][i] * ~a[k][j];
+	a[j][i] = x;
+      }
+}
+
+int main()
+{
+  static complex_16 work[5][5];
+  unsigned long cpu_facilities;
+
+  cpu_facilities = i386_cpuid ();
+  if (cpu_facilities & bit_SSE2)
+    test (work); 
+
+  return 0;
+}


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