From: Xi Ruoyao Date: Sat, 1 Mar 2025 03:46:49 +0000 (+0800) Subject: LoongArch: Don't expand atomic_fetch_sub_{hi, qi} to LL-SC loop if -mlam-bh X-Git-Tag: basepoints/gcc-17~5548 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d67bbce340351cfe7f30f1b17cba7635f18c8d5;p=thirdparty%2Fgcc.git LoongArch: Don't expand atomic_fetch_sub_{hi, qi} to LL-SC loop if -mlam-bh With -mlam-bh, we should negate the addend first, and use an amadd instruction. Disabling the expander makes the compiler do it correctly. gcc/ChangeLog: * config/loongarch/sync.md (atomic_fetch_sub): Disable if ISA_HAS_LAM_BH. --- diff --git a/gcc/config/loongarch/sync.md b/gcc/config/loongarch/sync.md index b6acfff3a61..60038258f29 100644 --- a/gcc/config/loongarch/sync.md +++ b/gcc/config/loongarch/sync.md @@ -661,7 +661,7 @@ (match_operand:SHORT 2 "reg_or_0_operand" "rJ")) (match_operand:SI 3 "const_int_operand")] ;; model UNSPEC_SYNC_OLD_OP))] - "" + "!ISA_HAS_LAM_BH" { union loongarch_gen_fn_ptrs generator; generator.fn_7 = gen_atomic_cas_value_sub_7_si;