Patchwork Fix -ftree-parallelize-loops=N -g (PR tree-optimization/46066)

login
register
mail settings
Submitter Jakub Jelinek
Date Oct. 20, 2010, 7:25 p.m.
Message ID <20101020192558.GO18103@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/68467/
State New
Headers show

Comments

Jakub Jelinek - Oct. 20, 2010, 7:25 p.m.
Hi!

create_parallel_loop assumes the last statement in latch must be def stmt
for cvar_next, which is not necessarily true if there are debug stmts after
it.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2010-10-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46066
	* tree-parloops.c (create_parallel_loop): Use gsi_last_nondebug_bb
	instead of gsi_last_bb.

	* gcc.dg/autopar/pr46066.c: New test.


	Jakub
Richard Guenther - Oct. 20, 2010, 8:56 p.m.
On Wed, Oct 20, 2010 at 9:25 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> create_parallel_loop assumes the last statement in latch must be def stmt
> for cvar_next, which is not necessarily true if there are debug stmts after
> it.

It assumes many more strange things ... (it's really odd code, noticed that
when working on changing the gimple representation of conds ...)

> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

>
> 2010-10-20  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/46066
>        * tree-parloops.c (create_parallel_loop): Use gsi_last_nondebug_bb
>        instead of gsi_last_bb.
>
>        * gcc.dg/autopar/pr46066.c: New test.
>
> --- gcc/tree-parloops.c.jj      2010-08-20 16:05:40.000000000 +0200
> +++ gcc/tree-parloops.c 2010-10-20 10:49:38.000000000 +0200
> @@ -1451,7 +1451,7 @@ create_parallel_loop (struct loop *loop,
>           initvar);
>   cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
>
> -  gsi = gsi_last_bb (loop->latch);
> +  gsi = gsi_last_nondebug_bb (loop->latch);
>   gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next));
>   gsi_remove (&gsi, true);
>
> --- gcc/testsuite/gcc.dg/autopar/pr46066.c.jj   2010-10-20 11:24:00.000000000 +0200
> +++ gcc/testsuite/gcc.dg/autopar/pr46066.c      2010-10-20 11:04:05.000000000 +0200
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/46066 */
> +/* { dg-do compile } */
> +/* { dg-options "-fcompare-debug -O -ftree-parallelize-loops=4" } */
> +
> +void
> +parloop (int N)
> +{
> +  int i, j, ii;
> +  int x[400][10][400];
> +  for (ii = 0; ii < N; ii++)
> +    for (i = 0; i < N; i++)
> +      for (j = 0; j < N; j++)
> +       x[i][j][ii] = 3;
> +  for (i = 0; i < N; i++)
> +    for (j = 0; j < N; j++)
> +      if (x[i][j][0] != 3)
> +       __builtin_abort ();
> +}
>
>        Jakub
>

Patch

--- gcc/tree-parloops.c.jj	2010-08-20 16:05:40.000000000 +0200
+++ gcc/tree-parloops.c	2010-10-20 10:49:38.000000000 +0200
@@ -1451,7 +1451,7 @@  create_parallel_loop (struct loop *loop,
 	   initvar);
   cvar_next = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
 
-  gsi = gsi_last_bb (loop->latch);
+  gsi = gsi_last_nondebug_bb (loop->latch);
   gcc_assert (gsi_stmt (gsi) == SSA_NAME_DEF_STMT (cvar_next));
   gsi_remove (&gsi, true);
 
--- gcc/testsuite/gcc.dg/autopar/pr46066.c.jj	2010-10-20 11:24:00.000000000 +0200
+++ gcc/testsuite/gcc.dg/autopar/pr46066.c	2010-10-20 11:04:05.000000000 +0200
@@ -0,0 +1,18 @@ 
+/* PR tree-optimization/46066 */
+/* { dg-do compile } */
+/* { dg-options "-fcompare-debug -O -ftree-parallelize-loops=4" } */
+
+void
+parloop (int N)
+{
+  int i, j, ii;
+  int x[400][10][400];
+  for (ii = 0; ii < N; ii++)
+    for (i = 0; i < N; i++)
+      for (j = 0; j < N; j++)
+	x[i][j][ii] = 3;
+  for (i = 0; i < N; i++)
+    for (j = 0; j < N; j++)
+      if (x[i][j][0] != 3)
+	__builtin_abort ();
+}