https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125628
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
diff --git a/gcc/config/mips/sync.md b/gcc/config/mips/sync.md
index 1d0a977066b..d968503f89c 100644
--- a/gcc/config/mips/sync.md
+++ b/gcc/config/mips/sync.md
@@ -172,21 +172,21 @@ (define_expand "sync_old_<optab><mode>"
})
;; Helper insn for sync_old_<optab><mode>
(define_insn "sync_old_<optab>_12"
[(set (match_operand:SI 0 "register_operand" "=&d")
(match_operand:SI 1 "memory_operand" "+ZC"))
(set (match_dup 1)
(unspec_volatile:SI
[(match_operand:SI 2 "register_operand" "d")
(match_operand:SI 3 "register_operand" "d")
- (atomic_hiqi_op:SI (match_dup 0)
+ (atomic_hiqi_op:SI (match_dup 1)
(match_operand:SI 4 "reg_or_0_operand" "dJ"))]
UNSPEC_SYNC_OLD_OP_12))
(clobber (match_scratch:SI 5 "=&d"))]
"GENERATE_LL_SC"
{ return mips_output_sync_loop (insn, operands); }
[(set_attr "sync_insn1" "<insn>")
It seems this had been wrong for many years. I've no idea why it only started
to manifest with GCC 16...