diff mbox

vect-70.c fails on spu-elf

Message ID OFB42E8F48.B7807DC7-ONC22578D7.0045D091-C22578D7.00472286@il.ibm.com
State New
Headers show

Commit Message

Ira Rosen July 24, 2011, 12:56 p.m. UTC
"Ulrich Weigand" <uweigand@de.ibm.com> wrote on 22/07/2011 05:05:57 PM:

> Hi Ira,
>
> gcc.dg/vect/vect-70.c fails sporadically on spu-elf, because the local
> variable "tmp1" exceeds local store size (it is over 1MB in size), and
> thus the stack wraps around.
>
> Dorit had originally fixed this by reducing the size of the array:
> http://gcc.gnu.org/ml/gcc-patches/2006-12/msg00018.html
>
> but a later patch by Honza increased the array size again:
> http://gcc.gnu.org/ml/gcc-patches/2009-05/msg00586.html
>
> (note that the size of "tmp1" increases with the *fourth* power of N).
>
> Any suggestions how to fix this?  Maybe decrease N again and instead
> prevent unrolling via command line switch?

There is no flag for this unrolling, but we can run the test with -O1
instead of -O2 (and with N=12) by renaming vect-70.c to O1-vect-70.c (see
the attached patch).

> Maybe just decrease
> *some* dimensions of the tmp1 array?

This can help too, if it is small enough:


(I checked these patches only on x86_64-suse-linux).

Ira
(See attached file: vect-70-patch.txt)


>
> Thanks,
> Ulrich
>
> --
>   Dr. Ulrich Weigand
>   GNU Toolchain for Linux on System z and Cell BE
>   Ulrich.Weigand@de.ibm.com
Index: vect-70.c
===================================================================
--- vect-70.c   (revision 176495)
+++ vect-70.c   (working copy)
@@ -1,69 +0,0 @@
-/* { dg-require-effective-target vect_int } */
-
-#include <stdarg.h>
-#include "tree-vect.h"
-
-#define N 24
-
-struct s{
-  int m;
-  int n[N][N][N];
-};
-
-struct test1{
-  struct s a; /* array a.n is unaligned */
-  int b;
-  int c;
-  struct s e[N]; /* array e.n is aligned */
-};
-
-__attribute__ ((noinline))
-int main1 ()
-{
-  int i,j;
-  struct test1 tmp1;
-
-  for (i = 0; i < N; i++)
-    for (j = 3; j < N-3; j++)
-      {
-        tmp1.e[i].n[1][2][j] = 8;
-      }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    for (j = 3; j < N-3; j++)
-    {
-      if (tmp1.e[i].n[1][2][j] != 8)
-          abort ();
-    }
-
-  /* not consecutive */
-  for (i = 0; i < N; i++)
-    for (j = 3; j < N-3; j++)
-      {
-        tmp1.e[j].n[1][2][j] = 8;
-      }
-
-  /* check results:  */
-  for (i = 0; i < N; i++)
-    for (j = 3; j < N-3; j++)
-    {
-      if (tmp1.e[j].n[1][2][j] != 8)
-          abort ();
-    }
-
-  return 0;
-}
-
-int main (void)
-{
-  check_vect ();
-
-  return main1 ();
-}
-
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" {target { vector_alignment_reachable} } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" {target {{! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
Index: O1-vect-70.c
===================================================================
--- O1-vect-70.c        (revision 0)
+++ O1-vect-70.c        (revision 0)
@@ -0,0 +1,69 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 12
+
+struct s{
+  int m;
+  int n[N][N][N];
+};
+
+struct test1{
+  struct s a; /* array a.n is unaligned */
+  int b;
+  int c;
+  struct s e[N]; /* array e.n is aligned */
+};
+
+__attribute__ ((noinline))
+int main1 ()
+{
+  int i,j;
+  struct test1 tmp1;
+
+  for (i = 0; i < N; i++)
+    for (j = 3; j < N-3; j++)
+      {
+        tmp1.e[i].n[1][2][j] = 8;
+      }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    for (j = 3; j < N-3; j++)
+    {
+      if (tmp1.e[i].n[1][2][j] != 8)
+          abort ();
+    }
+
+  /* not consecutive */
+  for (i = 0; i < N; i++)
+    for (j = 3; j < N-3; j++)
+      {
+        tmp1.e[j].n[1][2][j] = 8;
+      }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    for (j = 3; j < N-3; j++)
+    {
+      if (tmp1.e[j].n[1][2][j] != 8)
+          abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{
+  check_vect ();
+
+  return main1 ();
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" {target { vector_alignment_reachable} } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" {target {{! vector_alignment_reachable} && {! vect_hw_misalign} } } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff mbox

Patch

Index: vect-70.c
===================================================================
--- vect-70.c   (revision 176495)
+++ vect-70.c   (working copy)
@@ -7,7 +7,7 @@ 

 struct s{
   int m;
-  int n[N][N][N];
+  int n[N/6][N/6][N];
 };

 struct test1{