From: Michael Munday Date: Wed, 27 Aug 2025 22:07:36 +0000 (+0100) Subject: cmd/compile: remove sign extension before MULW on riscv64 X-Git-Tag: go1.26rc1~991 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=27ce6e4e26;p=gostls13.git 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 Auto-Submit: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Keith Randall Reviewed-by: Cherry Mui --- 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]