From 7789966286a97c2e60140c7108c6df8238436dbe Mon Sep 17 00:00:00 2001 From: WANG Xuerui Date: Sat, 11 Mar 2023 22:26:39 +0800 Subject: [PATCH] cmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64 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 TryBot-Result: Gopher Robot Run-TryBot: Wayne Zuo Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui --- src/cmd/compile/internal/loong64/ggen.go | 6 +----- src/runtime/asm_loong64.s | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cmd/compile/internal/loong64/ggen.go b/src/cmd/compile/internal/loong64/ggen.go index c6fd1a65a1..8a24d2f295 100644 --- a/src/cmd/compile/internal/loong64/ggen.go +++ b/src/cmd/compile/internal/loong64/ggen.go @@ -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 } diff --git a/src/runtime/asm_loong64.s b/src/runtime/asm_loong64.s index 60641d0aee..a64b0adf9c 100644 --- a/src/runtime/asm_loong64.s +++ b/src/runtime/asm_loong64.s @@ -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 -- 2.51.0