1
0
mirror of https://github.com/golang/go synced 2024-11-22 18:44:54 -07:00

cmd/compile: add intrinsic for MulUintptr on arm64

This CL adds intrinsic for runtime/internal/math.MulUintptr on arm64

Benchmark         master     ThisCL(ns/op)   delta
MulUintptr/small  0.95ns     0.79ns          -16%
MulUintptr/large  1.31ns     0.95ns          -27.6%

Change-Id: Ic7b453ad502826beffe93ce5531b8ba752312a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/419556
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
This commit is contained in:
ruinan 2022-07-21 05:16:11 +00:00 committed by Gopher Robot
parent f15761b50b
commit d654117075
3 changed files with 35 additions and 1 deletions

View File

@ -2977,3 +2977,8 @@
=> (Move [sz] dst src mem)
((REV|REVW) ((REV|REVW) p)) => p
// runtime/internal/math.MulUintptr intrinsics
(Select0 (Mul64uover x y)) => (MUL x y)
(Select1 (Mul64uover x y)) => (NotEqual (CMPconst (UMULH <typ.UInt64> x y) [0]))

View File

@ -27362,6 +27362,18 @@ func rewriteValueARM64_OpSelect0(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Select0 (Mul64uover x y))
// result: (MUL x y)
for {
if v_0.Op != OpMul64uover {
break
}
y := v_0.Args[1]
x := v_0.Args[0]
v.reset(OpARM64MUL)
v.AddArg2(x, y)
return true
}
return false
}
func rewriteValueARM64_OpSelect1(v *Value) bool {
@ -27415,6 +27427,23 @@ func rewriteValueARM64_OpSelect1(v *Value) bool {
v.AddArg(v0)
return true
}
// match: (Select1 (Mul64uover x y))
// result: (NotEqual (CMPconst (UMULH <typ.UInt64> x y) [0]))
for {
if v_0.Op != OpMul64uover {
break
}
y := v_0.Args[1]
x := v_0.Args[0]
v.reset(OpARM64NotEqual)
v0 := b.NewValue0(v.Pos, OpARM64CMPconst, types.TypeFlags)
v0.AuxInt = int64ToAuxInt(0)
v1 := b.NewValue0(v.Pos, OpARM64UMULH, typ.UInt64)
v1.AddArg2(x, y)
v0.AddArg(v1)
v.AddArg(v0)
return true
}
return false
}
func rewriteValueARM64_OpSelectN(v *Value) bool {

View File

@ -3908,7 +3908,7 @@ func InitTables() {
}
return s.newValue2(ssa.OpMul64uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1])
},
sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.RISCV64)
sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.RISCV64, sys.ARM64)
alias("runtime", "mulUintptr", "runtime/internal/math", "MulUintptr", all...)
add("runtime", "KeepAlive",
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {