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 target/35771: Call expander ignores type alignment


My fix for PR 35767 isn't correct. When we have to be consistent
when checking canonical type for parameter passing.  We have
to use canonical type throughout ix86_function_arg_boundary, including
contains_aligned_value_p.  The easiest way is to convert to
canonical type first if needed. I am testing it on Linux/ia32 and
Linux/Intel64. OK for trunk if it passes?

Thanks.


H.J.
---
gcc/

2008-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35771
	* config/i386/i386.c (ix86_function_arg_boundary): Use
	canonical type if needed.

gcc/testsuite/

2008-05-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/35771
	* gcc.dg/torture/pr35771.h: New.
	* gcc.dg/torture/pr35771-1.c: Likewise.
	* gcc.dg/torture/pr35771-2.c: Likewise.
	* gcc.dg/torture/pr35771-3.c: Likewise.

Index: gcc/testsuite/gcc.dg/torture/pr35771-1.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr35771-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr35771-1.c	(revision 0)
@@ -0,0 +1,8 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+
+typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128
+
+#include "pr35771.h"
Index: gcc/testsuite/gcc.dg/torture/pr35771-2.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr35771-2.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr35771-2.c	(revision 0)
@@ -0,0 +1,8 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+
+typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128d
+
+#include "pr35771.h"
Index: gcc/testsuite/gcc.dg/torture/pr35771.h
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr35771.h	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr35771.h	(revision 0)
@@ -0,0 +1,40 @@
+typedef TYPE __attribute__((aligned(1))) unaligned;
+
+#include "cpuid.h"
+
+extern void abort (void);
+
+
+TYPE  __attribute__((noinline))
+foo (TYPE a1, TYPE a2, TYPE a3, TYPE a4,
+     TYPE a5, TYPE a6, TYPE a7, TYPE a8,
+     int b1, int b2, int b3, int b4, int b5, int b6, int b7, unaligned y)
+{
+  return y;
+}
+
+void
+do_test (void)
+{
+  unaligned x;
+  TYPE y = { 0 };
+  x = y; 
+  y = foo (y, y, y, y, y, y, y, y, 1, 2, 3, 4, 5, 6, -1, x);
+  if (__builtin_memcmp (&y, &x, sizeof (y)) != 0)
+    abort ();
+}
+
+int
+main (void)
+{
+  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)
+    do_test ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.dg/torture/pr35771-3.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr35771-3.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr35771-3.c	(revision 0)
@@ -0,0 +1,8 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-msse2" } */
+
+typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
+
+#define TYPE __m128i
+
+#include "pr35771.h"
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c	(revision 136136)
+++ gcc/config/i386/i386.c	(working copy)
@@ -4639,10 +4639,11 @@ ix86_function_arg_boundary (enum machine
   int align;
   if (type)
     {
-      if (TYPE_STRUCTURAL_EQUALITY_P (type))
-	align = TYPE_ALIGN (type);
-      else
-	align = TYPE_ALIGN (TYPE_CANONICAL (type));
+      /* Since canonical type is used for call, we convert it to
+	 canonical type if needed.  */
+      if (!TYPE_STRUCTURAL_EQUALITY_P (type))
+	type = TYPE_CANONICAL (type);
+      align = TYPE_ALIGN (type);
     }
   else
     align = GET_MODE_ALIGNMENT (mode);


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