]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64
authorWANG Xuerui <git@xen0n.name>
Sat, 11 Mar 2023 14:26:39 +0000 (22:26 +0800)
committerM Zhuo <mzh@golangcn.org>
Wed, 15 Mar 2023 07:18:43 +0000 (07:18 +0000)
The canonical LoongArch NOP instruction form is "andi r0, r0, 0", as
described in the LoongArch Reference Manual Volume 1, Section 2.2.1.10.
We currently use NOR instead, which may or may not change anything (e.g.
performance on less capable micro-architectures) but is deviation from
upstream standards nevertheless. Fix them to use the explicit hardware
NOP which happens to be supported as `NOOP`.

Change-Id: I0a799a1da959e9c3b582feb88202df2bab0ab23a
Reviewed-on: https://go-review.googlesource.com/c/go/+/475615
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/loong64/ggen.go
src/runtime/asm_loong64.s

index c6fd1a65a10650c5d35868252d3f06c82b431d31..8a24d2f295abf5bd8c4f024a7d046bf5071790a8 100644 (file)
@@ -50,10 +50,6 @@ func zerorange(pp *objw.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog
 }
 
 func ginsnop(pp *objw.Progs) *obj.Prog {
-       p := pp.Prog(loong64.ANOR)
-       p.From.Type = obj.TYPE_REG
-       p.From.Reg = loong64.REG_R0
-       p.To.Type = obj.TYPE_REG
-       p.To.Reg = loong64.REG_R0
+       p := pp.Prog(loong64.ANOOP)
        return p
 }
index 60641d0aee8a31cd5b0156a346649e2e6ddb3b81..a64b0adf9cbcfbb86e39c11bf150fc5fb7468fb9 100644 (file)
@@ -618,10 +618,10 @@ TEXT _cgo_topofstack(SB),NOSPLIT,$16
 // The top-most function running on a goroutine
 // returns to goexit+PCQuantum.
 TEXT runtime·goexit(SB),NOSPLIT|NOFRAME|TOPFRAME,$0-0
-       NOR     R0, R0  // NOP
+       NOOP
        JAL     runtime·goexit1(SB)    // does not return
        // traceback from goexit1 must hit code range of goexit
-       NOR     R0, R0  // NOP
+       NOOP
 
 TEXT ·checkASM(SB),NOSPLIT,$0-1
        MOVW    $1, R19