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]

Re: i386 PATCH for target/13685


On Thu, Sep 07, 2006 at 10:00:40PM -0700, Eric Christopher wrote:
> Jason Merrill wrote:
> >H. J. Lu wrote:
> >>On Thu, Sep 07, 2006 at 08:26:45PM -0400, Jason Merrill wrote:
> >>>The testcase in 13685 breaks because -Os implies a smaller 
> >>>PREFERRED_STACK_BOUNDARY than SSE requires.  This patch causes us to 
> >>>use the 128-bit boundary if SSE is enabled, which fixes the bug.
> >
> >>I think it is a bad idea for -Os to change ABI. There are several bugs
> >>open because of it. You can have a program compiled with -Os calling
> >>a library compiled with -msee. The program will crash since -Os
> >>uses a different ABI. The easiest way to fix is for -Os not to change
> >>the ABI automatically.
> >
> >I wouldn't mind changing the stack boundary to always be 128 bits.
> >
> 
> FWIW me either :)
> 

Here is the patch.


H.J.
----
gcc/

2006-09-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/13685
	PR target/27537
	PR target/28621
	* config/i386/i386.c (override_options): Always default to 16
	byte stack boundary.

gcc/testsuite/

2006-09-08  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/13685
	* gcc.target/i386/pr13685.c: New test.

--- gcc/config/i386/i386.c.stack	2006-09-08 07:33:44.000000000 -0700
+++ gcc/config/i386/i386.c	2006-09-08 07:36:27.000000000 -0700
@@ -1908,11 +1908,10 @@ override_options (void)
     }
 
   /* Validate -mpreferred-stack-boundary= value, or provide default.
-     The default of 128 bits is for Pentium III's SSE __m128, but we
-     don't want additional code to keep the stack aligned when
-     optimizing for code size.  */
-  ix86_preferred_stack_boundary
-    = ((TARGET_MACHO || TARGET_SSE || !optimize_size) ? 128 : 32);
+     The default of 128 bits is for Pentium III's SSE __m128.  We can't
+     change it because of optimize_size.  Otherwise, we can't mix object
+     files compiled with -Os and -On.  */
+  ix86_preferred_stack_boundary = 128;
   if (ix86_preferred_stack_boundary_string)
     {
       i = atoi (ix86_preferred_stack_boundary_string);
--- gcc/testsuite/gcc.target/i386/pr13685.c.stack	2006-09-08 08:58:32.000000000 -0700
+++ gcc/testsuite/gcc.target/i386/pr13685.c	2006-09-08 08:58:13.000000000 -0700
@@ -0,0 +1,39 @@
+/* PR target/13685 */
+/* { dg-do run } */
+/* { dg-options "-Os -msse" } */
+#include <stdlib.h>
+#include <stdio.h>
+#include <xmmintrin.h>
+#include "../../gcc.dg/i386-cpuid.h"
+
+void foo (__m128 *, __m64 *, int);
+
+__m128 xmm0 = { 0 };
+__m64 mm0 = { 0 };
+
+int
+main ()
+{
+  unsigned long cpu_facilities = i386_cpuid ();
+  
+  if ((cpu_facilities & (bit_MMX | bit_SSE | bit_CMOV))
+      != (bit_MMX | bit_SSE | bit_CMOV))
+    /* If host has no SSE support, pass.  */
+    return 0;
+
+  foo (&xmm0, &mm0, 4);
+  return 0;
+}
+
+void
+foo (__m128 *dst, __m64 *src, int n)
+{
+  __m128 xmm0 = { 0 };
+  while (n > 64)
+    {
+      puts ("");
+      xmm0 = _mm_cvtpi32_ps (xmm0, *src);
+      *dst = xmm0;
+      n--;
+    }
+}


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