diff options
| author | Michael Munday <mike.munday@lowrisc.org> | 2025-08-27 23:07:36 +0100 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-08-29 10:50:58 -0700 |
| commit | 27ce6e4e2649f0db113f376d0d5f60185f3c74a3 (patch) | |
| tree | daa4369692001f099caae07479acc9bed9af5e5e /src/cmd/compile | |
| parent | 84b070bfb15ca598af5d1113e6666587499ad26d (diff) | |
| download | go-27ce6e4e2649f0db113f376d0d5f60185f3c74a3.tar.xz | |
cmd/compile: remove sign extension before MULW on riscv64
These sign extensions aren't necessary.
Change-Id: Id68ea596a18b30949d4605b2885f02e49e42d8e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/699595
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile')
| -rw-r--r-- | src/cmd/compile/internal/ssa/_gen/RISCV64.rules | 4 | ||||
| -rw-r--r-- | src/cmd/compile/internal/ssa/rewriteRISCV64.go | 44 |
2 files changed, 5 insertions, 43 deletions
diff --git a/src/cmd/compile/internal/ssa/_gen/RISCV64.rules b/src/cmd/compile/internal/ssa/_gen/RISCV64.rules index 9d79fc34e8..151f3412ce 100644 --- a/src/cmd/compile/internal/ssa/_gen/RISCV64.rules +++ b/src/cmd/compile/internal/ssa/_gen/RISCV64.rules @@ -12,9 +12,7 @@ (Mul64 ...) => (MUL ...) (Mul64uhilo ...) => (LoweredMuluhilo ...) (Mul64uover ...) => (LoweredMuluover ...) -(Mul32 ...) => (MULW ...) -(Mul16 x y) => (MULW (SignExt16to32 x) (SignExt16to32 y)) -(Mul8 x y) => (MULW (SignExt8to32 x) (SignExt8to32 y)) +(Mul(32|16|8) ...) => (MULW ...) (Mul(64|32)F ...) => (FMUL(D|S) ...) (Div(64|32)F ...) => (FDIV(D|S) ...) diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go index c78ae89561..1e80669672 100644 --- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go +++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -405,7 +405,8 @@ func rewriteValueRISCV64(v *Value) bool { case OpMove: return rewriteValueRISCV64_OpMove(v) case OpMul16: - return rewriteValueRISCV64_OpMul16(v) + v.Op = OpRISCV64MULW + return true case OpMul32: v.Op = OpRISCV64MULW return true @@ -425,7 +426,8 @@ func rewriteValueRISCV64(v *Value) bool { v.Op = OpRISCV64LoweredMuluover return true case OpMul8: - return rewriteValueRISCV64_OpMul8(v) + v.Op = OpRISCV64MULW + return true case OpNeg16: v.Op = OpRISCV64NEG return true @@ -3255,44 +3257,6 @@ func rewriteValueRISCV64_OpMove(v *Value) bool { } return false } -func rewriteValueRISCV64_OpMul16(v *Value) bool { - v_1 := v.Args[1] - v_0 := v.Args[0] - b := v.Block - typ := &b.Func.Config.Types - // match: (Mul16 x y) - // result: (MULW (SignExt16to32 x) (SignExt16to32 y)) - for { - x := v_0 - y := v_1 - v.reset(OpRISCV64MULW) - v0 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) - v0.AddArg(x) - v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) - v1.AddArg(y) - v.AddArg2(v0, v1) - return true - } -} -func rewriteValueRISCV64_OpMul8(v *Value) bool { - v_1 := v.Args[1] - v_0 := v.Args[0] - b := v.Block - typ := &b.Func.Config.Types - // match: (Mul8 x y) - // result: (MULW (SignExt8to32 x) (SignExt8to32 y)) - for { - x := v_0 - y := v_1 - v.reset(OpRISCV64MULW) - v0 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) - v0.AddArg(x) - v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) - v1.AddArg(y) - v.AddArg2(v0, v1) - return true - } -} func rewriteValueRISCV64_OpNeq16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] |
