diff mbox

Don't ICE in vectorizer when testing if a pattern stmt is used by another pattern stmt (PR tree-optimization/52073)

Message ID 20120201164013.GS18768@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 1, 2012, 4:40 p.m. UTC
Hi!

vinfo_for_stmt can't be used on stmts outside of the current loop.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/52073
	* tree-vect-stmts.c (vect_mark_relevant): When checking uses of
	a pattern stmt for pattern uses, ignore uses outside of the loop.

	* gcc.c-torture/compile/pr52073.c: New test.


	Jakub

Comments

Ira Rosen Feb. 2, 2012, 6:49 a.m. UTC | #1
Jakub Jelinek <jakub@redhat.com> wrote on 01/02/2012 06:40:13 PM:


> Hi!
>

Hi,

> vinfo_for_stmt can't be used on stmts outside of the current loop.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Yes.

Thanks,
Ira

>
> 2012-02-01  Jakub Jelinek  <jakub@redhat.com>
>
>    PR tree-optimization/52073
>    * tree-vect-stmts.c (vect_mark_relevant): When checking uses of
>    a pattern stmt for pattern uses, ignore uses outside of the loop.
>
>    * gcc.c-torture/compile/pr52073.c: New test.
>
> --- gcc/tree-vect-stmts.c.jj   2012-01-22 16:02:10.000000000 +0100
> +++ gcc/tree-vect-stmts.c   2012-02-01 10:33:58.847815421 +0100
> @@ -150,6 +150,8 @@ vect_mark_relevant (VEC(gimple,heap) **w
>            use_operand_p use_p;
>            gimple use_stmt;
>            tree lhs;
> +     loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
> +     struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
>
>            if (is_gimple_assign (stmt))
>              lhs = gimple_assign_lhs (stmt);
> @@ -166,6 +168,9 @@ vect_mark_relevant (VEC(gimple,heap) **w
>          continue;
>        use_stmt = USE_STMT (use_p);
>
> +      if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
> +        continue;
> +
>        if (vinfo_for_stmt (use_stmt)
>            && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt)))
>          {
> --- gcc/testsuite/gcc.c-torture/compile/pr52073.c.jj   2012-02-01
> 10:39:13.041003562 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr52073.c   2012-02-01 10:
> 38:51.000000000 +0100
> @@ -0,0 +1,28 @@
> +/* PR tree-optimization/52073 */
> +
> +int a, b, c, d, e, f;
> +
> +void
> +foo (int x)
> +{
> +  e = 1;
> +  for (;;)
> +    {
> +      int g = c;
> +      if (x)
> +   {
> +     if (e)
> +       continue;
> +     while (a)
> +       --f;
> +   }
> +      else
> +   for (b = 5; b; b--)
> +     {
> +       d = g;
> +       g = 0 == d;
> +     }
> +      if (!g)
> +   x = 0;
> +    }
> +}
>
>    Jakub
>
Richard Biener Feb. 2, 2012, 8:56 a.m. UTC | #2
On Wed, 1 Feb 2012, Jakub Jelinek wrote:

> Hi!
> 
> vinfo_for_stmt can't be used on stmts outside of the current loop.
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2012-02-01  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/52073
> 	* tree-vect-stmts.c (vect_mark_relevant): When checking uses of
> 	a pattern stmt for pattern uses, ignore uses outside of the loop.
> 
> 	* gcc.c-torture/compile/pr52073.c: New test.
> 
> --- gcc/tree-vect-stmts.c.jj	2012-01-22 16:02:10.000000000 +0100
> +++ gcc/tree-vect-stmts.c	2012-02-01 10:33:58.847815421 +0100
> @@ -150,6 +150,8 @@ vect_mark_relevant (VEC(gimple,heap) **w
>            use_operand_p use_p;
>            gimple use_stmt;
>            tree lhs;
> +	  loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
> +	  struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
>  
>            if (is_gimple_assign (stmt))
>              lhs = gimple_assign_lhs (stmt);
> @@ -166,6 +168,9 @@ vect_mark_relevant (VEC(gimple,heap) **w
>  		  continue;
>  		use_stmt = USE_STMT (use_p);
>  
> +		if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
> +		  continue;
> +
>  		if (vinfo_for_stmt (use_stmt)
>  		    && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt)))
>  		  {
> --- gcc/testsuite/gcc.c-torture/compile/pr52073.c.jj	2012-02-01 10:39:13.041003562 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr52073.c	2012-02-01 10:38:51.000000000 +0100
> @@ -0,0 +1,28 @@
> +/* PR tree-optimization/52073 */
> +
> +int a, b, c, d, e, f;
> +
> +void
> +foo (int x)
> +{
> +  e = 1;
> +  for (;;)
> +    {
> +      int g = c;
> +      if (x)
> +	{
> +	  if (e)
> +	    continue;
> +	  while (a)
> +	    --f;
> +	}
> +      else
> +	for (b = 5; b; b--)
> +	  {
> +	    d = g;
> +	    g = 0 == d;
> +	  }
> +      if (!g)
> +	x = 0;
> +    }
> +}
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/tree-vect-stmts.c.jj	2012-01-22 16:02:10.000000000 +0100
+++ gcc/tree-vect-stmts.c	2012-02-01 10:33:58.847815421 +0100
@@ -150,6 +150,8 @@  vect_mark_relevant (VEC(gimple,heap) **w
           use_operand_p use_p;
           gimple use_stmt;
           tree lhs;
+	  loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
+	  struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
 
           if (is_gimple_assign (stmt))
             lhs = gimple_assign_lhs (stmt);
@@ -166,6 +168,9 @@  vect_mark_relevant (VEC(gimple,heap) **w
 		  continue;
 		use_stmt = USE_STMT (use_p);
 
+		if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
+		  continue;
+
 		if (vinfo_for_stmt (use_stmt)
 		    && STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt)))
 		  {
--- gcc/testsuite/gcc.c-torture/compile/pr52073.c.jj	2012-02-01 10:39:13.041003562 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr52073.c	2012-02-01 10:38:51.000000000 +0100
@@ -0,0 +1,28 @@ 
+/* PR tree-optimization/52073 */
+
+int a, b, c, d, e, f;
+
+void
+foo (int x)
+{
+  e = 1;
+  for (;;)
+    {
+      int g = c;
+      if (x)
+	{
+	  if (e)
+	    continue;
+	  while (a)
+	    --f;
+	}
+      else
+	for (b = 5; b; b--)
+	  {
+	    d = g;
+	    g = 0 == d;
+	  }
+      if (!g)
+	x = 0;
+    }
+}