Skip to content

Commit

Permalink
cmd/compile/internal, runtime: use NOOP for hardware NOPs on loong64
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Wayne Zuo <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
  • Loading branch information
xen0n authored and mengzhuo committed Mar 15, 2023
1 parent b5c8ae9 commit 7789966
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions src/cmd/compile/internal/loong64/ggen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions src/runtime/asm_loong64.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7789966

Please sign in to comment.