]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lower-bitint: Don't use m_loads for loads used in GIMPLE_ASM [PR113464]
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Jan 2024 09:01:43 +0000 (10:01 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 19 Jan 2024 09:01:43 +0000 (10:01 +0100)
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.

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
gcc/testsuite/gcc.dg/bitint-75.c [new file with mode: 0644]

index e48125daec992ee14b3d57c2eea0c755c252d60c..be11d77fe4dd815e235de90f1f5001df1d90f29f 100644 (file)
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/bitint-75.c b/gcc/testsuite/gcc.dg/bitint-75.c
new file mode 100644 (file)
index 0000000..dd8292e
--- /dev/null
@@ -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" } */
+}