public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] bitint: Don't move debug stmts from before returns_twice calls [PR114628]
@ 2024-04-09  6:37 Jakub Jelinek
  2024-04-09  6:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-04-09  6:37 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

Debug stmts are allowed by the verifier before the returns_twice calls.
More importantly, they don't have a lhs, so the current handling of
arg_stmts statements to force them on the edges ICEs.

The following patch just keeps them where they were before.

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

2024-04-09  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/114628
	* gimple-lower-bitint.cc (gimple_lower_bitint): Keep debug stmts
	before returns_twice calls as is, don't push them into arg_stmts
	vector/move to edges.

	* gcc.dg/bitint-105.c: New test.

--- gcc/gimple-lower-bitint.cc.jj	2024-04-04 10:46:52.698026863 +0200
+++ gcc/gimple-lower-bitint.cc	2024-04-08 15:42:19.719892644 +0200
@@ -7172,8 +7172,13 @@ gimple_lower_bitint (void)
 	  gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (stmt));
 	  while (gsi_stmt (gsi) != stmt)
 	    {
-	      arg_stmts.safe_push (gsi_stmt (gsi));
-	      gsi_remove (&gsi, false);
+	      if (is_gimple_debug (gsi_stmt (gsi)))
+		gsi_next (&gsi);
+	      else
+		{
+		  arg_stmts.safe_push (gsi_stmt (gsi));
+		  gsi_remove (&gsi, false);
+		}
 	    }
 	  gimple *g;
 	  basic_block bb = NULL;
--- gcc/testsuite/gcc.dg/bitint-105.c.jj	2024-04-08 16:00:07.843630530 +0200
+++ gcc/testsuite/gcc.dg/bitint-105.c	2024-04-08 15:49:28.687175492 +0200
@@ -0,0 +1,29 @@
+/* PR middle-end/114628 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -g" } */
+
+int foo (int);
+#if __BITINT_MAXWIDTH__ >= 129
+__attribute__((returns_twice)) int bar (_BitInt(129) x);
+
+void
+baz (int x, _BitInt(129) y)
+{
+  void *q[] = { &&l1, &&l2 };
+l2:
+  x = foo (foo (3));
+  bar (y);
+  goto *q[x & 1];
+l1:;
+}
+
+void
+qux (int x, _BitInt(129) y)
+{
+  void *q[] = { &&l1, &&l2 };
+l2:
+  x = foo (foo (3));
+  bar (y);
+l1:;
+}
+#endif

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] bitint: Don't move debug stmts from before returns_twice calls [PR114628]
  2024-04-09  6:37 [PATCH] bitint: Don't move debug stmts from before returns_twice calls [PR114628] Jakub Jelinek
@ 2024-04-09  6:49 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-04-09  6:49 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 9 Apr 2024, Jakub Jelinek wrote:

> Hi!
> 
> Debug stmts are allowed by the verifier before the returns_twice calls.

Huh, interesting ;)

> More importantly, they don't have a lhs, so the current handling of
> arg_stmts statements to force them on the edges ICEs.
> 
> The following patch just keeps them where they were before.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Richard.

> 2024-04-09  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/114628
> 	* gimple-lower-bitint.cc (gimple_lower_bitint): Keep debug stmts
> 	before returns_twice calls as is, don't push them into arg_stmts
> 	vector/move to edges.
> 
> 	* gcc.dg/bitint-105.c: New test.
> 
> --- gcc/gimple-lower-bitint.cc.jj	2024-04-04 10:46:52.698026863 +0200
> +++ gcc/gimple-lower-bitint.cc	2024-04-08 15:42:19.719892644 +0200
> @@ -7172,8 +7172,13 @@ gimple_lower_bitint (void)
>  	  gimple_stmt_iterator gsi = gsi_after_labels (gimple_bb (stmt));
>  	  while (gsi_stmt (gsi) != stmt)
>  	    {
> -	      arg_stmts.safe_push (gsi_stmt (gsi));
> -	      gsi_remove (&gsi, false);
> +	      if (is_gimple_debug (gsi_stmt (gsi)))
> +		gsi_next (&gsi);
> +	      else
> +		{
> +		  arg_stmts.safe_push (gsi_stmt (gsi));
> +		  gsi_remove (&gsi, false);
> +		}
>  	    }
>  	  gimple *g;
>  	  basic_block bb = NULL;
> --- gcc/testsuite/gcc.dg/bitint-105.c.jj	2024-04-08 16:00:07.843630530 +0200
> +++ gcc/testsuite/gcc.dg/bitint-105.c	2024-04-08 15:49:28.687175492 +0200
> @@ -0,0 +1,29 @@
> +/* PR middle-end/114628 */
> +/* { dg-do compile { target bitint } } */
> +/* { dg-options "-O2 -g" } */
> +
> +int foo (int);
> +#if __BITINT_MAXWIDTH__ >= 129
> +__attribute__((returns_twice)) int bar (_BitInt(129) x);
> +
> +void
> +baz (int x, _BitInt(129) y)
> +{
> +  void *q[] = { &&l1, &&l2 };
> +l2:
> +  x = foo (foo (3));
> +  bar (y);
> +  goto *q[x & 1];
> +l1:;
> +}
> +
> +void
> +qux (int x, _BitInt(129) y)
> +{
> +  void *q[] = { &&l1, &&l2 };
> +l2:
> +  x = foo (foo (3));
> +  bar (y);
> +l1:;
> +}
> +#endif
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-09  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-09  6:37 [PATCH] bitint: Don't move debug stmts from before returns_twice calls [PR114628] Jakub Jelinek
2024-04-09  6:49 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).