lower-bitint: Don't use m_loads for loads used in GIMPLE_ASM [PR113464]

Message ID Zao5Fd7H6TekzRo5@tucnak
State Unresolved
Headers
Series lower-bitint: Don't use m_loads for loads used in GIMPLE_ASM [PR113464] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek Jan. 19, 2024, 8:55 a.m. UTC
  Hi!

Like for GIMPLE_PHIs or calls, even for GIMPLE_ASMs we want
a corresponding VAR_DECL assigned for lhs SSA_NAMEs of loads
from memory, as even GIMPLE_ASM relies on those VAR_DECLs to exist.

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

2024-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/113464
	* gimple-lower-bitint.cc (gimple_lower_bitint): Don't try to
	optimize loads into GIMPLE_ASM stmts.

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


	Jakub
  

Comments

Richard Biener Jan. 19, 2024, 8:57 a.m. UTC | #1
On Fri, 19 Jan 2024, Jakub Jelinek wrote:

> Hi!
> 
> Like for GIMPLE_PHIs or calls, even for GIMPLE_ASMs we want
> a corresponding VAR_DECL assigned for lhs SSA_NAMEs of loads
> from memory, as even GIMPLE_ASM relies on those VAR_DECLs to exist.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

> 2024-01-19  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/113464
> 	* gimple-lower-bitint.cc (gimple_lower_bitint): Don't try to
> 	optimize loads into GIMPLE_ASM stmts.
> 
> 	* gcc.dg/bitint-75.c: New test.
> 
> --- gcc/gimple-lower-bitint.cc.jj	2024-01-18 08:44:08.337270271 +0100
> +++ gcc/gimple-lower-bitint.cc	2024-01-18 19:57:11.791976322 +0100
> @@ -6249,7 +6249,8 @@ gimple_lower_bitint (void)
>  		  if (is_gimple_debug (use_stmt))
>  		    continue;
>  		  if (gimple_code (use_stmt) == GIMPLE_PHI
> -		      || is_gimple_call (use_stmt))
> +		      || is_gimple_call (use_stmt)
> +		      || gimple_code (use_stmt) == GIMPLE_ASM)
>  		    {
>  		      optimizable_load = false;
>  		      break;
> --- gcc/testsuite/gcc.dg/bitint-75.c.jj	2024-01-18 20:08:21.710557536 +0100
> +++ gcc/testsuite/gcc.dg/bitint-75.c	2024-01-18 20:07:18.017447734 +0100
> @@ -0,0 +1,11 @@
> +/* PR tree-optimization/113464 */
> +/* { dg-do compile { target bitint65535 } } */
> +/* { dg-options "-O2 -w -std=gnu23" } */
> +
> +_BitInt(65532) i;
> +
> +void
> +foo (void)
> +{
> +  __asm__ ("" : "+r" (i));	/* { dg-error "impossible constraint" } */
> +}
> 
> 	Jakub
> 
>
  

Patch

--- gcc/gimple-lower-bitint.cc.jj	2024-01-18 08:44:08.337270271 +0100
+++ gcc/gimple-lower-bitint.cc	2024-01-18 19:57:11.791976322 +0100
@@ -6249,7 +6249,8 @@  gimple_lower_bitint (void)
 		  if (is_gimple_debug (use_stmt))
 		    continue;
 		  if (gimple_code (use_stmt) == GIMPLE_PHI
-		      || is_gimple_call (use_stmt))
+		      || is_gimple_call (use_stmt)
+		      || gimple_code (use_stmt) == GIMPLE_ASM)
 		    {
 		      optimizable_load = false;
 		      break;
--- gcc/testsuite/gcc.dg/bitint-75.c.jj	2024-01-18 20:08:21.710557536 +0100
+++ gcc/testsuite/gcc.dg/bitint-75.c	2024-01-18 20:07:18.017447734 +0100
@@ -0,0 +1,11 @@ 
+/* PR tree-optimization/113464 */
+/* { dg-do compile { target bitint65535 } } */
+/* { dg-options "-O2 -w -std=gnu23" } */
+
+_BitInt(65532) i;
+
+void
+foo (void)
+{
+  __asm__ ("" : "+r" (i));	/* { dg-error "impossible constraint" } */
+}