]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add intrinsics for runtime/internal/math on MIPS64x
authorMeng Zhuo <mengzhuo1203@gmail.com>
Sat, 29 Feb 2020 03:23:29 +0000 (11:23 +0800)
committerCherry Zhang <cherryyz@google.com>
Mon, 2 Mar 2020 16:12:20 +0000 (16:12 +0000)
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 <mengzhuo1203@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/MIPS64.rules
src/cmd/compile/internal/ssa/rewriteMIPS64.go

index a89af236f457c3e067a6f4d97ece29d170f18d5e..f2a472bde6371a5b2db093f9c4646297262cbeee 100644 (file)
@@ -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])
index 6df2b3e6b9f4cfbb3fe13ea3eebdb31618cb986f..be05dc71c0420e5ded91f2d004d5f15b993926d5 100644 (file)
@@ -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 <typ.UInt64> (MULVU x y))
+(Select1 (Mul64uover x y)) -> (SGTU <typ.Bool> (Select0 <typ.UInt64> (MULVU x y)) (MOVVconst <typ.UInt64> [0]))
 
 (Hmul64 x y) -> (Select0 (MULV x y))
 (Hmul64u x y) -> (Select0 (MULVU x y))
index 6736fcd5602ecba02340b217820766e4986ea2f7..346fa6f28ee3f24dbdd17623e2d26b47bff3f6b5 100644 (file)
@@ -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 <typ.UInt64> (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 <typ.Bool> (Select0 <typ.UInt64> (MULVU x y)) (MOVVconst <typ.UInt64> [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 {