]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
LoongArch: Don't expand atomic_fetch_sub_{hi, qi} to LL-SC loop if -mlam-bh
authorXi Ruoyao <xry111@xry111.site>
Sat, 1 Mar 2025 03:46:49 +0000 (11:46 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Mon, 18 Aug 2025 01:09:35 +0000 (09:09 +0800)
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<SHORT:mode>):
Disable if ISA_HAS_LAM_BH.

gcc/config/loongarch/sync.md

index b6acfff3a611a159d8eed598e1ecedd00ed60fe7..60038258f294331acd2cb02b45b072ab04ac1fd5 100644 (file)
                        (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;