]> Cypherpunks repositories - gostls13.git/commitdiff
internal/runtime/atomic: reset wrong jump target in Cas{,64} on loong64
authorGuoqi Chen <chenguoqi@loongson.cn>
Wed, 27 Aug 2025 06:45:58 +0000 (14:45 +0800)
committerabner chenc <chenguoqi@loongson.cn>
Mon, 1 Sep 2025 01:32:58 +0000 (18:32 -0700)
The implementation here needs to be consistent with ssa.OpLOONG64LoweredAtomicCas{32,64},
which was ignored in CL 613396.

Change-Id: I72e8d2318e0c1935cc3a35ab5098f8a84e48bcd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/699395
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
src/internal/runtime/atomic/atomic_loong64.s

index 95d3e2bdab8c869df05e1eec82fd8f80be3cc817..4215af24febaa2d56715d56fdb18f65df7e91e56 100644 (file)
@@ -19,7 +19,7 @@ TEXT ·Cas(SB), NOSPLIT, $0-17
        MOVW    new+12(FP), R6
 
        MOVBU   internal∕cpu·Loong64+const_offsetLOONG64HasLAMCAS(SB), R8
-       BEQ     R8, cas_again
+       BEQ     R8, ll_sc
        MOVV    R5, R7  // backup old value
        AMCASDBW        R6, (R4), R5
        BNE     R7, R5, cas_fail0
@@ -30,6 +30,7 @@ cas_fail0:
        MOVB    R0, ret+16(FP)
        RET
 
+ll_sc:
        // Implemented using the ll-sc instruction pair
        DBAR    $0x14   // LoadAcquire barrier
 cas_again:
@@ -60,7 +61,7 @@ TEXT ·Cas64(SB), NOSPLIT, $0-25
        MOVV    new+16(FP), R6
 
        MOVBU   internal∕cpu·Loong64+const_offsetLOONG64HasLAMCAS(SB), R8
-       BEQ     R8, cas64_again
+       BEQ     R8, ll_sc_64
        MOVV    R5, R7  // backup old value
        AMCASDBV        R6, (R4), R5
        BNE     R7, R5, cas64_fail0
@@ -71,6 +72,7 @@ cas64_fail0:
        MOVB    R0, ret+24(FP)
        RET
 
+ll_sc_64:
        // Implemented using the ll-sc instruction pair
        DBAR    $0x14
 cas64_again: