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: PR middle-end/37010: -Os passes __m128 on stack with wrong alignment


We can't guarantee that simple push insn will work with parameters
which require alignment > PARM_BOUNDARY. In this case, we have to
preallocate stack and move __m128 onto stack ourselves. I am
testing it on Linux/x86-64.  OK for trunk if it passes?

Thanks.


H.J.
----
gcc/

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

	PR middle-end/37010
	* calls.c (initialize_argument_information): Must preallocate
	stack if the alignment of any parameters > PARM_BOUNDARY.

gcc/testsuite/

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

	PR middle-end/37010
	* gcc.target/i386/push-1.c: New.

--- gcc/calls.c.align	2008-07-30 20:53:22.000000000 -0700
+++ gcc/calls.c	2008-08-02 17:29:49.000000000 -0700
@@ -1162,14 +1162,24 @@ initialize_argument_information (int num
       if (args[i].reg == 0 || args[i].partial != 0
 	  || reg_parm_stack_space > 0
 	  || args[i].pass_on_stack)
-	locate_and_pad_parm (mode, type,
+	{
+	  locate_and_pad_parm (mode, type,
 #ifdef STACK_PARMS_IN_REG_PARM_AREA
-			     1,
+			       1,
 #else
-			     args[i].reg != 0,
+			       args[i].reg != 0,
 #endif
-			     args[i].pass_on_stack ? 0 : args[i].partial,
-			     fndecl, args_size, &args[i].locate);
+			       args[i].pass_on_stack ? 0 : args[i].partial,
+			       fndecl, args_size, &args[i].locate);
+
+	  /* If the alignment of this parameter > PARM_BOUNDARY,
+	     we must move this parameter onto stack ourselves
+	     since push insn won't guarantee alignment beyond
+	     PARM_BOUNDARY.  */
+	  if (args[i].reg == 0
+	      && args[i].locate.boundary > PARM_BOUNDARY)
+	    *must_preallocate = 1;
+	}
 #ifdef BLOCK_REG_PADDING
       else
 	/* The argument is passed entirely in registers.  See at which
--- gcc/testsuite/gcc.target/i386/push-1.c.align	2008-08-02 17:23:27.000000000 -0700
+++ gcc/testsuite/gcc.target/i386/push-1.c	2008-08-02 17:28:40.000000000 -0700
@@ -0,0 +1,16 @@
+/* PR middle-end/37010 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-w -msse2 -Os" } */
+
+#include <emmintrin.h>
+
+extern void foo (__m128 x, __m128 y ,__m128 z ,__m128 a, int size);
+
+void
+bar (void)
+{
+  __m128 x = { 1.0 };
+  foo (x, x, x, x, 5);
+}
+
+/* { dg-final { scan-assembler-not "movups" } } */


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