cmd/compile: combine negation and word sign extension on riscv64

Use NEGW to produce a negated and sign extended word, rather than doing
the same via two instructions:

   neg     t0, t0
   sext.w  a0, t0

Becomes:

   negw    t0, t0

Change-Id: I824ab25001bd3304bdbd435e7b244fcc036ef212
Reviewed-on: https://go-review.googlesource.com/c/go/+/652319
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Joel Sing 2022-10-12 17:37:23 +11:00
parent 10d070668c
commit 21417518a9
3 changed files with 15 additions and 1 deletions

View file

@ -174,7 +174,7 @@ func AddAddSubSimplify(a, b, c int) int {
}
func NegToInt32(a int) int {
// riscv64: "NEG","MOVW"
// riscv64: "NEGW",-"MOVW"
r := int(int32(-a))
return r
}