diff options
author | Xi Ruoyao <xry111@xry111.site> | 2023-11-06 16:06:08 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@xry111.site> | 2023-11-15 19:30:57 +0800 |
commit | 4d86dc51e34d2a5695b617afeb56e3414836a79a (patch) | |
tree | 375e8f58471a6f40d9aa37857fbc46c74da82d06 /libgomp/acc_prof.h | |
parent | 452476db0c705caeac8712d560fc16ced0ca5226 (diff) | |
download | gcc-4d86dc51e34d2a5695b617afeb56e3414836a79a.zip gcc-4d86dc51e34d2a5695b617afeb56e3414836a79a.tar.gz gcc-4d86dc51e34d2a5695b617afeb56e3414836a79a.tar.bz2 |
LoongArch: Remove redundant barrier instructions before LL-SC loops
This is isomorphic to the LLVM changes [1-2].
On LoongArch, the LL and SC instructions has memory barrier semantics:
- LL: <memory-barrier> + <load-exclusive>
- SC: <store-conditional> + <memory-barrier>
But the compare and swap operation is allowed to fail, and if it fails
the SC instruction is not executed, thus the guarantee of acquiring
semantics cannot be ensured. Therefore, an acquire barrier needs to be
generated when failure_memorder includes an acquire operation.
On CPUs implementing LoongArch v1.10 or later, "dbar 0b10100" is an
acquire barrier; on CPUs implementing LoongArch v1.00, it is a full
barrier. So it's always enough for acquire semantics. OTOH if an
acquire semantic is not needed, we still needs the "dbar 0x700" as the
load-load barrier like all LL-SC loops.
[1]:https://github.com/llvm/llvm-project/pull/67391
[2]:https://github.com/llvm/llvm-project/pull/69339
gcc/ChangeLog:
* config/loongarch/loongarch.cc
(loongarch_memmodel_needs_release_fence): Remove.
(loongarch_cas_failure_memorder_needs_acquire): New static
function.
(loongarch_print_operand): Redefine 'G' for the barrier on CAS
failure.
* config/loongarch/sync.md (atomic_cas_value_strong<mode>):
Remove the redundant barrier before the LL instruction, and
emit an acquire barrier on failure if needed by
failure_memorder.
(atomic_cas_value_cmp_and_7_<mode>): Likewise.
(atomic_cas_value_add_7_<mode>): Remove the unnecessary barrier
before the LL instruction.
(atomic_cas_value_sub_7_<mode>): Likewise.
(atomic_cas_value_and_7_<mode>): Likewise.
(atomic_cas_value_xor_7_<mode>): Likewise.
(atomic_cas_value_or_7_<mode>): Likewise.
(atomic_cas_value_nand_7_<mode>): Likewise.
(atomic_cas_value_exchange_7_<mode>): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/cas-acquire.c: New test.
Diffstat (limited to 'libgomp/acc_prof.h')
0 files changed, 0 insertions, 0 deletions