Patchwork Fix vectorizer ICE (PR tree-optimization/55831)

login
register
mail settings
Submitter Jakub Jelinek
Date Dec. 31, 2012, 3:26 p.m.
Message ID <20121231152644.GK2315@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/208865/
State New
Headers show

Comments

Jakub Jelinek - Dec. 31, 2012, 3:26 p.m.
Hi!

The following testcase ICEs because get_initial_def_for_induction inserts
stmts before gsi_start_bb, which is wrong for basic blocks that start with
labels, as then the labels are in the middle of a basic block.

Ok for trunk?

2012-12-31  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/55831
	* tree-vect-loop.c (get_initial_def_for_induction): Use
	gsi_after_labels instead of gsi_start_bb.

	* gcc.dg/pr55831.c: New test.


	Jakub
Richard Guenther - Dec. 31, 2012, 4:01 p.m.
On Mon, Dec 31, 2012 at 4:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The following testcase ICEs because get_initial_def_for_induction inserts
> stmts before gsi_start_bb, which is wrong for basic blocks that start with
> labels, as then the labels are in the middle of a basic block.
>
> Ok for trunk?

Obvious indeed.

Thanks,
Richard.

> 2012-12-31  Jakub Jelinek  <jakub@redhat.com>
>
>         PR tree-optimization/55831
>         * tree-vect-loop.c (get_initial_def_for_induction): Use
>         gsi_after_labels instead of gsi_start_bb.
>
>         * gcc.dg/pr55831.c: New test.
>
> --- gcc/tree-vect-loop.c.jj     2012-11-27 14:33:14.000000000 +0100
> +++ gcc/tree-vect-loop.c        2012-12-31 15:10:02.211716876 +0100
> @@ -3406,7 +3406,7 @@ get_initial_def_for_induction (gimple iv
>           build1 (VIEW_CONVERT_EXPR, resvectype, induc_def), NULL_TREE);
>        induc_def = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt);
>        gimple_assign_set_lhs (new_stmt, induc_def);
> -      si = gsi_start_bb (bb);
> +      si = gsi_after_labels (bb);
>        gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
>        set_vinfo_for_stmt (new_stmt,
>                           new_stmt_vec_info (new_stmt, loop_vinfo, NULL));
> --- gcc/testsuite/gcc.dg/pr55831.c.jj   2012-12-31 15:25:11.484514159 +0100
> +++ gcc/testsuite/gcc.dg/pr55831.c      2012-12-31 15:13:35.000000000 +0100
> @@ -0,0 +1,22 @@
> +/* PR tree-optimization/55831 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -fstrict-overflow -ftree-vectorize -Wno-unused-label" } */
> +
> +int g;
> +short p, q;
> +
> +void
> +f (void)
> +{
> +  short a = p, b = q, i;
> +
> +  if (a)
> +    {
> +    label:
> +      for (i = 0; i < 8; i++)
> +       b ^= a++;
> +
> +      if (!b)
> +       g = 0;
> +    }
> +}
>
>         Jakub

Patch

--- gcc/tree-vect-loop.c.jj	2012-11-27 14:33:14.000000000 +0100
+++ gcc/tree-vect-loop.c	2012-12-31 15:10:02.211716876 +0100
@@ -3406,7 +3406,7 @@  get_initial_def_for_induction (gimple iv
 	  build1 (VIEW_CONVERT_EXPR, resvectype, induc_def), NULL_TREE);
       induc_def = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt);
       gimple_assign_set_lhs (new_stmt, induc_def);
-      si = gsi_start_bb (bb);
+      si = gsi_after_labels (bb);
       gsi_insert_before (&si, new_stmt, GSI_SAME_STMT);
       set_vinfo_for_stmt (new_stmt,
 			  new_stmt_vec_info (new_stmt, loop_vinfo, NULL));
--- gcc/testsuite/gcc.dg/pr55831.c.jj	2012-12-31 15:25:11.484514159 +0100
+++ gcc/testsuite/gcc.dg/pr55831.c	2012-12-31 15:13:35.000000000 +0100
@@ -0,0 +1,22 @@ 
+/* PR tree-optimization/55831 */
+/* { dg-do compile } */
+/* { dg-options "-O -fstrict-overflow -ftree-vectorize -Wno-unused-label" } */
+
+int g;
+short p, q;
+
+void
+f (void)
+{
+  short a = p, b = q, i;
+
+  if (a)
+    {
+    label:
+      for (i = 0; i < 8; i++)
+	b ^= a++;
+
+      if (!b)
+	g = 0;
+    }
+}