From: Meng Zhuo Date: Sat, 29 Feb 2020 03:23:29 +0000 (+0800) Subject: cmd/compile: add intrinsics for runtime/internal/math on MIPS64x X-Git-Tag: go1.15beta1~973 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ab7ecea0c8dff908dfcad8c9091b71c6051bb94a;p=gostls13.git cmd/compile: add intrinsics for runtime/internal/math on MIPS64x name old time/op new time/op delta MulUintptr/small 8.42ns ± 0% 5.93ns ± 0% -29.66% (p=0.000 n=9+10) MulUintptr/large 11.1ns ± 0% 7.4ns ± 0% -33.17% (p=0.000 n=10+9) Change-Id: I6659a886389660461fc2c90bd248243f6e7c29d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/210897 Run-TryBot: Meng Zhuo TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index a89af236f4..f2a472bde6 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -3269,7 +3269,7 @@ func init() { } return s.newValue2(ssa.OpMul64uover, types.NewTuple(types.Types[TUINT], types.Types[TUINT]), args[0], args[1]) }, - sys.AMD64, sys.I386) + sys.AMD64, sys.I386, sys.MIPS64) add("runtime", "KeepAlive", func(s *state, n *Node, args []*ssa.Value) *ssa.Value { data := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, args[0]) diff --git a/src/cmd/compile/internal/ssa/gen/MIPS64.rules b/src/cmd/compile/internal/ssa/gen/MIPS64.rules index 6df2b3e6b9..be05dc71c0 100644 --- a/src/cmd/compile/internal/ssa/gen/MIPS64.rules +++ b/src/cmd/compile/internal/ssa/gen/MIPS64.rules @@ -11,6 +11,8 @@ (Mul(64|32|16|8) x y) -> (Select1 (MULVU x y)) (Mul(32|64)F ...) -> (MUL(F|D) ...) (Mul64uhilo ...) -> (MULVU ...) +(Select0 (Mul64uover x y)) -> (Select1 (MULVU x y)) +(Select1 (Mul64uover x y)) -> (SGTU (Select0 (MULVU x y)) (MOVVconst [0])) (Hmul64 x y) -> (Select0 (MULV x y)) (Hmul64u x y) -> (Select0 (MULVU x y)) diff --git a/src/cmd/compile/internal/ssa/rewriteMIPS64.go b/src/cmd/compile/internal/ssa/rewriteMIPS64.go index 6736fcd560..346fa6f28e 100644 --- a/src/cmd/compile/internal/ssa/rewriteMIPS64.go +++ b/src/cmd/compile/internal/ssa/rewriteMIPS64.go @@ -6927,6 +6927,24 @@ func rewriteValueMIPS64_OpRsh8x8(v *Value) bool { } func rewriteValueMIPS64_OpSelect0(v *Value) bool { v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select0 (Mul64uover x y)) + // result: (Select1 (MULVU x y)) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpSelect1) + v.Type = typ.UInt64 + v0 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v0.AddArg(x) + v0.AddArg(y) + v.AddArg(v0) + return true + } // match: (Select0 (DIVVU _ (MOVVconst [1]))) // result: (MOVVconst [0]) for { @@ -7010,6 +7028,29 @@ func rewriteValueMIPS64_OpSelect0(v *Value) bool { } func rewriteValueMIPS64_OpSelect1(v *Value) bool { v_0 := v.Args[0] + b := v.Block + typ := &b.Func.Config.Types + // match: (Select1 (Mul64uover x y)) + // result: (SGTU (Select0 (MULVU x y)) (MOVVconst [0])) + for { + if v_0.Op != OpMul64uover { + break + } + y := v_0.Args[1] + x := v_0.Args[0] + v.reset(OpMIPS64SGTU) + v.Type = typ.Bool + v0 := b.NewValue0(v.Pos, OpSelect0, typ.UInt64) + v1 := b.NewValue0(v.Pos, OpMIPS64MULVU, types.NewTuple(typ.UInt64, typ.UInt64)) + v1.AddArg(x) + v1.AddArg(y) + v0.AddArg(v1) + v.AddArg(v0) + v2 := b.NewValue0(v.Pos, OpMIPS64MOVVconst, typ.UInt64) + v2.AuxInt = 0 + v.AddArg(v2) + return true + } // match: (Select1 (MULVU x (MOVVconst [-1]))) // result: (NEGV x) for {