[llvm] [LoongArch] fix: Support LoongArch atomic memory operations with monotonic semantics (PR #112681)
Lu Weining via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 20:09:11 PDT 2024
SixWeining wrote:
About `atomic_load_sub`, seems we have something to optimize:
testcase:
```
#include <stdatomic.h>
int *fp2a(int **p) {
return __atomic_fetch_sub(p, 1, memory_order_relaxed);
}
```
gcc:
```
addi.w $r13,$r0,-1 # 0xffffffffffffffff
or $r12,$r4,$r0
amadd.d $r4,$r13,$r12,0
```
clang:
```
ori $a1, $zero, 1
sub.d $a2, $zero, $a1
amadd_db.d $a1, $a2, $a0
move $a0, $a1
```
But this can be done in a separate PR.
https://github.com/llvm/llvm-project/pull/112681
More information about the llvm-commits
mailing list