https://gcc.gnu.org/g:0dd775a6d5e63425dc7d09138ed4af670c5704eb

commit r16-9194-g0dd775a6d5e63425dc7d09138ed4af670c5704eb
Author: H.J. Lu <[email protected]>
Date:   Fri Jun 19 20:05:56 2026 +0800

    x86_cse: Skip JUMP from asm goto
    
    Skip a single set of JUMP came from asm goto:
    
    (jump_insn 9 2 111 2 (parallel [
                (set (reg:SI 134)
                    (asm_operands/v:SI ("") ("=r") 0 []
                         []
                         [
                            (label_ref:DI 10)
                        ] x.c:6))
                (clobber (reg:CC 17 flags))
            ]) "x.c":6:3 -1
         (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))
     -> 10)
    
    when checking the broadcast source.
    
    gcc/
    
            PR target/125883
            * config/i386/i386-features.cc (ix86_broadcast_inner): Skip JUMP
            from asm goto.
    
    gcc/testsuite/
    
            PR target/125883
            * gcc.target/i386/pr125883.c: New test.
    
    Signed-off-by: H.J. Lu <[email protected]>
    (cherry picked from commit d018a10f24c82f02f2c093b31e91c03917feb8a4)

Diff:
---
 gcc/config/i386/i386-features.cc         |  5 +++++
 gcc/testsuite/gcc.target/i386/pr125883.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index c0706c8935c6..cef1e24da341 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -3775,6 +3775,11 @@ ix86_broadcast_inner (rtx op, machine_mode mode,
     return nullptr;
 
   rtx_insn *insn = DF_REF_INSN (ref);
+
+  /* Skip JUMP which happens with asm goto.  */
+  if (JUMP_P (insn))
+    return nullptr;
+
   rtx set = single_set (insn);
   if (!set)
     return nullptr;
diff --git a/gcc/testsuite/gcc.target/i386/pr125883.c 
b/gcc/testsuite/gcc.target/i386/pr125883.c
new file mode 100644
index 000000000000..fe44c62e763a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr125883.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=x86-64" } */
+
+int a, b;
+int c[0], d[0];
+void
+foo (void)
+{
+  __asm__ goto("" : "=r"(a) : : : f);
+f:
+  for (; b; b++)
+    c[b] = d[b] = c[b] + a;
+}

Reply via email to