re PR tree-optimization/54894 (internal compiler error: in vect_get_vec_def_for_opera...
authorRichard Biener <rguenther@suse.de>
Fri, 12 Oct 2012 08:00:29 +0000 (08:00 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 12 Oct 2012 08:00:29 +0000 (08:00 +0000)
2012-10-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/54894
* tree-vect-stmts.c (get_vectype_for_scalar_type_and_size):
Handle over-aligned scalar types properly.

* gcc.dg/torture/pr54894.c: New testcase.

From-SVN: r192390

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr54894.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index fec50a2bbee87a0fa5d4ef129decd07394c19df3..c44c5ab7646a5dd594debc4b994c3a59b77861f3 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/54894
+       * tree-vect-stmts.c (get_vectype_for_scalar_type_and_size):
+       Handle over-aligned scalar types properly.
+
 2012-10-12  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/54760
index b35fe712ab22b58c0b7fbdb289dc773f850d2351..776727c88afb060c01f821447c2236550b1720bf 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-12  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/54894
+       * gcc.dg/torture/pr54894.c: New testcase.
+
 2012-10-12  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/51244
diff --git a/gcc/testsuite/gcc.dg/torture/pr54894.c b/gcc/testsuite/gcc.dg/torture/pr54894.c
new file mode 100644 (file)
index 0000000..277e371
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+
+typedef unsigned long long uint64_t;
+
+#define n 4096
+double A[n][n] __attribute__((aligned(16)));
+double B[n][n] __attribute__((aligned(16)));
+double C[n][n] __attribute__((aligned(16)));
+
+#define tilesize 128
+
+typedef double adouble __attribute__((__aligned__(16)));
+
+void foo ()
+{
+  int ih, jh, kh, il, kl, jl;
+  for (ih = 0; ih < n; ih += tilesize) 
+    for (jh = 0; jh < n; jh += tilesize)                 
+      for (kh = 0; kh < n; kh += tilesize)                      
+       for (il = 0; il < tilesize; ++il)
+         {
+           adouble *Ap = (adouble *)&A[ih+il][kh];
+           for (kl = 0; kl < tilesize; ++kl)
+             for (jl = 0; jl < tilesize; ++jl)
+               C[ih+il][jh+jl] += Ap[kl] * B[kh+kl][jh+jl];
+         }
+}
index 92eaac48a41f797b76832f7ca4d5cda0e66dc88d..e1b7b7a0e7b87450b50612bfe44ead433df08287 100644 (file)
@@ -6060,11 +6060,6 @@ get_vectype_for_scalar_type_and_size (tree scalar_type, unsigned size)
       && GET_MODE_CLASS (inner_mode) != MODE_FLOAT)
     return NULL_TREE;
 
-  /* We can't build a vector type of elements with alignment bigger than
-     their size.  */
-  if (nbytes < TYPE_ALIGN_UNIT (scalar_type))
-    return NULL_TREE;
-
   /* For vector types of elements whose mode precision doesn't
      match their types precision we use a element type of mode
      precision.  The vectorization routines will have to make sure
@@ -6086,6 +6081,11 @@ get_vectype_for_scalar_type_and_size (tree scalar_type, unsigned size)
       && !POINTER_TYPE_P (scalar_type))
     scalar_type = lang_hooks.types.type_for_mode (inner_mode, 1);
 
+  /* We can't build a vector type of elements with alignment bigger than
+     their size.  */
+  if (nbytes < TYPE_ALIGN_UNIT (scalar_type))
+    scalar_type = lang_hooks.types.type_for_mode (inner_mode, 1);
+
   /* If no size was supplied use the mode the target prefers.   Otherwise
      lookup a vector mode of the specified size.  */
   if (size == 0)