diff mbox series

isel: Fix up gimple_expand_vec_set_expr [PR105528]

Message ID YnoiPiPm0dPXFetR@tucnak
State New
Headers show
Series isel: Fix up gimple_expand_vec_set_expr [PR105528] | expand

Commit Message

Jakub Jelinek May 10, 2022, 8:28 a.m. UTC
Hi!

The following testcase ICEs (and only without -g), because we don't replace
one VEC_COND_EXPR with .VCOND* call.
We don't do that because gimple_expand_vec_set_expr adds some stmts before
*gsi and then uses gsi_remove to remove it.  gsi_remove moves the iterator
to the next stmt and in the caller we then do gsi_next before looking at
another stmt, which means we can skip processing of one stmt, which in this
case happened to be a VEC_COND_EXPR but with -g is some debug stmt in
between.  As we always emit some stmts before it, it is easy to update the
iterator to the last stmt emitted there, so that caller continues really
with the next stmt.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2022-05-10  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/105528
	* gimple-isel.cc (gimple_expand_vec_set_expr): After gsi_remove
	set *gsi to gsi_for_stmt (ass_stmt).  Fix up function comment.

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


	Jakub

Comments

Richard Biener May 10, 2022, 10:02 a.m. UTC | #1
On Tue, 10 May 2022, Jakub Jelinek wrote:

> Hi!
> 
> The following testcase ICEs (and only without -g), because we don't replace
> one VEC_COND_EXPR with .VCOND* call.
> We don't do that because gimple_expand_vec_set_expr adds some stmts before
> *gsi and then uses gsi_remove to remove it.  gsi_remove moves the iterator
> to the next stmt and in the caller we then do gsi_next before looking at
> another stmt, which means we can skip processing of one stmt, which in this
> case happened to be a VEC_COND_EXPR but with -g is some debug stmt in
> between.  As we always emit some stmts before it, it is easy to update the
> iterator to the last stmt emitted there, so that caller continues really
> with the next stmt.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

> 2022-05-10  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/105528
> 	* gimple-isel.cc (gimple_expand_vec_set_expr): After gsi_remove
> 	set *gsi to gsi_for_stmt (ass_stmt).  Fix up function comment.
> 
> 	* gcc.dg/pr105528.c: New test.
> 
> --- gcc/gimple-isel.cc.jj	2022-05-09 09:09:20.386472253 +0200
> +++ gcc/gimple-isel.cc	2022-05-09 11:28:27.295925124 +0200
> @@ -43,7 +43,7 @@ along with GCC; see the file COPYING3.
>  /* Expand all ARRAY_REF(VIEW_CONVERT_EXPR) gimple assignments into calls to
>     internal function based on vector type of selected expansion.
>     i.e.:
> -     VIEW_CONVERT_EXPR<int[4]>(u)[_1] =  = i_4(D);
> +     VIEW_CONVERT_EXPR<int[4]>(u)[_1] = i_4(D);
>     =>
>       _7 = u;
>       _8 = .VEC_SET (_7, i_4(D), _1);
> @@ -104,6 +104,7 @@ gimple_expand_vec_set_expr (struct funct
>  	  if (gsi_remove (gsi, true)
>  	      && gimple_purge_dead_eh_edges (bb))
>  	    cfg_changed = true;
> +	  *gsi = gsi_for_stmt (ass_stmt);
>  	}
>      }
>  
> --- gcc/testsuite/gcc.dg/pr105528.c.jj	2022-05-09 11:30:09.476529621 +0200
> +++ gcc/testsuite/gcc.dg/pr105528.c	2022-05-09 11:30:35.091179163 +0200
> @@ -0,0 +1,23 @@
> +/* PR tree-optimization/105528 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -Wno-psabi -fcompare-debug" } */
> +/* { dg-additional-options "-mavx512f" { target i?86-*-* x86_64-*-* } } */
> +
> +typedef unsigned V __attribute__((__vector_size__ (64)));
> +V g;
> +
> +V
> +bar (V v)
> +{
> +  V w;
> +  v <<= (V){(V){}[53]} >= v & 5;
> +  w[w[5]] -= ~0;
> +  v %= ~0;
> +  return v + w;
> +}
> +
> +void
> +foo (void)
> +{
> +  g -= (V){bar((V){~0})[3]};
> +}
> 
> 	Jakub
> 
>
diff mbox series

Patch

--- gcc/gimple-isel.cc.jj	2022-05-09 09:09:20.386472253 +0200
+++ gcc/gimple-isel.cc	2022-05-09 11:28:27.295925124 +0200
@@ -43,7 +43,7 @@  along with GCC; see the file COPYING3.
 /* Expand all ARRAY_REF(VIEW_CONVERT_EXPR) gimple assignments into calls to
    internal function based on vector type of selected expansion.
    i.e.:
-     VIEW_CONVERT_EXPR<int[4]>(u)[_1] =  = i_4(D);
+     VIEW_CONVERT_EXPR<int[4]>(u)[_1] = i_4(D);
    =>
      _7 = u;
      _8 = .VEC_SET (_7, i_4(D), _1);
@@ -104,6 +104,7 @@  gimple_expand_vec_set_expr (struct funct
 	  if (gsi_remove (gsi, true)
 	      && gimple_purge_dead_eh_edges (bb))
 	    cfg_changed = true;
+	  *gsi = gsi_for_stmt (ass_stmt);
 	}
     }
 
--- gcc/testsuite/gcc.dg/pr105528.c.jj	2022-05-09 11:30:09.476529621 +0200
+++ gcc/testsuite/gcc.dg/pr105528.c	2022-05-09 11:30:35.091179163 +0200
@@ -0,0 +1,23 @@ 
+/* PR tree-optimization/105528 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-psabi -fcompare-debug" } */
+/* { dg-additional-options "-mavx512f" { target i?86-*-* x86_64-*-* } } */
+
+typedef unsigned V __attribute__((__vector_size__ (64)));
+V g;
+
+V
+bar (V v)
+{
+  V w;
+  v <<= (V){(V){}[53]} >= v & 5;
+  w[w[5]] -= ~0;
+  v %= ~0;
+  return v + w;
+}
+
+void
+foo (void)
+{
+  g -= (V){bar((V){~0})[3]};
+}