aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewriteRISCV64.go
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2020-02-26 04:00:10 +1100
committerJoel Sing <joel@sing.id.au>2020-02-28 14:33:28 +0000
commit8955a56da015890f317d5f6919391503b854d93a (patch)
tree59483143777c46d5d25fe01103dd9f3c1b1ffd0f /src/cmd/compile/internal/ssa/rewriteRISCV64.go
parent44286d09c5fcdb703624fad6ce24306294cab1fe (diff)
downloadgo-8955a56da015890f317d5f6919391503b854d93a.tar.gz
go-8955a56da015890f317d5f6919391503b854d93a.zip
cmd/compile: improve SignExt32to64 on riscv64
SignExt32to64 can be implemented with a single ADDIW instruction, rather than the two shifts that are in use currently. Change-Id: Ie1bbaef4018f1ba5162773fc64fa5a887457cfc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/220922 Reviewed-by: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteRISCV64.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewriteRISCV64.go13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
index e25f80c5ca0..e4480dc3669 100644
--- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go
+++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go
@@ -4109,18 +4109,13 @@ func rewriteValueRISCV64_OpSignExt16to64(v *Value) bool {
}
func rewriteValueRISCV64_OpSignExt32to64(v *Value) bool {
v_0 := v.Args[0]
- b := v.Block
// match: (SignExt32to64 <t> x)
- // result: (SRAI [32] (SLLI <t> [32] x))
+ // result: (ADDIW [0] x)
for {
- t := v.Type
x := v_0
- v.reset(OpRISCV64SRAI)
- v.AuxInt = 32
- v0 := b.NewValue0(v.Pos, OpRISCV64SLLI, t)
- v0.AuxInt = 32
- v0.AddArg(x)
- v.AddArg(v0)
+ v.reset(OpRISCV64ADDIW)
+ v.AuxInt = 0
+ v.AddArg(x)
return true
}
}