]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove sign extension before MULW on riscv64
authorMichael Munday <mike.munday@lowrisc.org>
Wed, 27 Aug 2025 22:07:36 +0000 (23:07 +0100)
committerGopher Robot <gobot@golang.org>
Fri, 29 Aug 2025 17:50:58 +0000 (10:50 -0700)
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>
src/cmd/compile/internal/ssa/_gen/RISCV64.rules
src/cmd/compile/internal/ssa/rewriteRISCV64.go

index 9d79fc34e8732b9a843cc0092649f1defd9a7a7b..151f3412ce7c5a6b8efbf5a04bf128bf6a4a6358 100644 (file)
@@ -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) ...)
index c78ae89561910edc032adae4f78575307da776f6..1e80669672c2f452e5e6764c6366e8e1657403c9 100644 (file)
@@ -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]