mirror of
https://github.com/golang/go.git
synced 2026-04-05 02:40:11 +09:00
cmd/compile: (mips64x) optimize float32(abs|sqrt64(float64(x)))
Absorb unnecessary conversion between float32 and float64 if both src and dst are 32 bit. Ref: CL 733621 Updates #75463 Change-Id: I439f92aa3d940fa4979e76845c0893e43bf584af Reviewed-on: https://go-review.googlesource.com/c/go/+/739520 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joel Sing <joel@sing.id.au>
This commit is contained in:
@@ -352,6 +352,7 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
|
||||
ssa.OpMIPS64MOVVgpfp,
|
||||
ssa.OpMIPS64NEGF,
|
||||
ssa.OpMIPS64NEGD,
|
||||
ssa.OpMIPS64ABSF,
|
||||
ssa.OpMIPS64ABSD,
|
||||
ssa.OpMIPS64SQRTF,
|
||||
ssa.OpMIPS64SQRTD:
|
||||
|
||||
@@ -692,6 +692,9 @@
|
||||
(Select0 (DIVVU _ (MOVVconst [1]))) => (MOVVconst [0]) // mod
|
||||
(Select0 (DIVVU x (MOVVconst [c]))) && isPowerOfTwo(c) => (ANDconst [c-1] x) // mod
|
||||
|
||||
// Absorb conversion between 32 bit and 64 bit if both src and dst are 32 bit.
|
||||
(MOVDF ((ABS|SQRT)D (MOVFD x))) => ((ABS|SQRT)F x)
|
||||
|
||||
// generic simplifications
|
||||
(ADDV x (NEGV y)) => (SUBV x y)
|
||||
(SUBV x (NEGV y)) => (ADDV x y)
|
||||
|
||||
@@ -193,6 +193,7 @@ func init() {
|
||||
{name: "NEGV", argLength: 1, reg: gp11}, // -arg0
|
||||
{name: "NEGF", argLength: 1, reg: fp11, asm: "NEGF"}, // -arg0, float32
|
||||
{name: "NEGD", argLength: 1, reg: fp11, asm: "NEGD"}, // -arg0, float64
|
||||
{name: "ABSF", argLength: 1, reg: fp11, asm: "ABSF"}, // abs(arg0), float32
|
||||
{name: "ABSD", argLength: 1, reg: fp11, asm: "ABSD"}, // abs(arg0), float64
|
||||
{name: "SQRTD", argLength: 1, reg: fp11, asm: "SQRTD"}, // sqrt(arg0), float64
|
||||
{name: "SQRTF", argLength: 1, reg: fp11, asm: "SQRTF"}, // sqrt(arg0), float32
|
||||
|
||||
@@ -4845,6 +4845,7 @@ const (
|
||||
OpMIPS64NEGV
|
||||
OpMIPS64NEGF
|
||||
OpMIPS64NEGD
|
||||
OpMIPS64ABSF
|
||||
OpMIPS64ABSD
|
||||
OpMIPS64SQRTD
|
||||
OpMIPS64SQRTF
|
||||
@@ -74577,6 +74578,19 @@ var opcodeTable = [...]opInfo{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ABSF",
|
||||
argLen: 1,
|
||||
asm: mips.AABSF,
|
||||
reg: regInfo{
|
||||
inputs: []inputInfo{
|
||||
{0, 1152921504338411520}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
|
||||
},
|
||||
outputs: []outputInfo{
|
||||
{0, 1152921504338411520}, // F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 F16 F17 F18 F19 F20 F21 F22 F23 F24 F25 F26 F27 F28 F29 F30 F31
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ABSD",
|
||||
argLen: 1,
|
||||
|
||||
@@ -332,6 +332,8 @@ func rewriteValueMIPS64(v *Value) bool {
|
||||
return rewriteValueMIPS64_OpMIPS64MOVBreg(v)
|
||||
case OpMIPS64MOVBstore:
|
||||
return rewriteValueMIPS64_OpMIPS64MOVBstore(v)
|
||||
case OpMIPS64MOVDF:
|
||||
return rewriteValueMIPS64_OpMIPS64MOVDF(v)
|
||||
case OpMIPS64MOVDload:
|
||||
return rewriteValueMIPS64_OpMIPS64MOVDload(v)
|
||||
case OpMIPS64MOVDstore:
|
||||
@@ -3192,6 +3194,40 @@ func rewriteValueMIPS64_OpMIPS64MOVBstore(v *Value) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValueMIPS64_OpMIPS64MOVDF(v *Value) bool {
|
||||
v_0 := v.Args[0]
|
||||
// match: (MOVDF (ABSD (MOVFD x)))
|
||||
// result: (ABSF x)
|
||||
for {
|
||||
if v_0.Op != OpMIPS64ABSD {
|
||||
break
|
||||
}
|
||||
v_0_0 := v_0.Args[0]
|
||||
if v_0_0.Op != OpMIPS64MOVFD {
|
||||
break
|
||||
}
|
||||
x := v_0_0.Args[0]
|
||||
v.reset(OpMIPS64ABSF)
|
||||
v.AddArg(x)
|
||||
return true
|
||||
}
|
||||
// match: (MOVDF (SQRTD (MOVFD x)))
|
||||
// result: (SQRTF x)
|
||||
for {
|
||||
if v_0.Op != OpMIPS64SQRTD {
|
||||
break
|
||||
}
|
||||
v_0_0 := v_0.Args[0]
|
||||
if v_0_0.Op != OpMIPS64MOVFD {
|
||||
break
|
||||
}
|
||||
x := v_0_0.Args[0]
|
||||
v.reset(OpMIPS64SQRTF)
|
||||
v.AddArg(x)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func rewriteValueMIPS64_OpMIPS64MOVDload(v *Value) bool {
|
||||
v_1 := v.Args[1]
|
||||
v_0 := v.Args[0]
|
||||
|
||||
Reference in New Issue
Block a user