cmd/compile: (mips64x) optimize float32(abs|sqrt64(float64(x)))
Ref: #733621
Updates #75463
diff --git a/src/cmd/compile/internal/mips64/ssa.go b/src/cmd/compile/internal/mips64/ssa.go
index 6eae8fe..e3f9c17 100644
--- a/src/cmd/compile/internal/mips64/ssa.go
+++ b/src/cmd/compile/internal/mips64/ssa.go
@@ -353,6 +353,7 @@
ssa.OpMIPS64MOVVgpfp,
ssa.OpMIPS64NEGF,
ssa.OpMIPS64NEGD,
+ ssa.OpMIPS64ABSF,
ssa.OpMIPS64ABSD,
ssa.OpMIPS64SQRTF,
ssa.OpMIPS64SQRTD:
diff --git a/src/cmd/compile/internal/ssa/_gen/MIPS64.rules b/src/cmd/compile/internal/ssa/_gen/MIPS64.rules
index da6ae94..d0a60c6 100644
--- a/src/cmd/compile/internal/ssa/_gen/MIPS64.rules
+++ b/src/cmd/compile/internal/ssa/_gen/MIPS64.rules
@@ -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)
diff --git a/src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go b/src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go
index fe3afba..151ecc3 100644
--- a/src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go
+++ b/src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go
@@ -194,6 +194,7 @@
{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
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
index a84fc16..bd03718 100644
--- a/src/cmd/compile/internal/ssa/opGen.go
+++ b/src/cmd/compile/internal/ssa/opGen.go
@@ -4829,6 +4829,7 @@
OpMIPS64NEGV
OpMIPS64NEGF
OpMIPS64NEGD
+ OpMIPS64ABSF
OpMIPS64ABSD
OpMIPS64SQRTD
OpMIPS64SQRTF
@@ -74329,6 +74330,19 @@
},
},
{
+ 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,
asm: mips.AABSD,
diff --git a/src/cmd/compile/internal/ssa/rewriteMIPS64.go b/src/cmd/compile/internal/ssa/rewriteMIPS64.go
index eae67a2..59e6d2e 100644
--- a/src/cmd/compile/internal/ssa/rewriteMIPS64.go
+++ b/src/cmd/compile/internal/ssa/rewriteMIPS64.go
@@ -332,6 +332,8 @@
return rewriteValueMIPS64_OpMIPS64MOVBreg(v)
case OpMIPS64MOVBstore:
return rewriteValueMIPS64_OpMIPS64MOVBstore(v)
+ case OpMIPS64MOVDF:
+ return rewriteValueMIPS64_OpMIPS64MOVDF(v)
case OpMIPS64MOVDload:
return rewriteValueMIPS64_OpMIPS64MOVDload(v)
case OpMIPS64MOVDstore:
@@ -3191,6 +3193,40 @@
}
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]
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Added a mips64 trybot because trust-but-verify
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Run-TryBot | +1 |
TRY=mips64,mips64le
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Gopher RobotSlowBots beginning. Status page: https://farmer.golang.org/try?commit=95c8964e
Dmitri ShuralyovBuild is still in progress... Status page: https://farmer.golang.org/try?commit=95c8964e
Failed on linux-mips64-rtrk: https://storage.googleapis.com/go-build-log/95c8964e/linux-mips64-rtrk_1385efad.log
Other builds still in progress; subsequent failure notices suppressed until final report.Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test *exactly* your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.
The requested legacy slowbots keep not completing on patch set 1. Removing Run-TryBot+1 vote since it's not adding new information.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Removed Run-TryBot+1 by Julian Zhu <jz53...@gmail.com>
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +2 |
Gopher RobotSlowBots beginning. Status page: https://farmer.golang.org/try?commit=95c8964e
Dmitri ShuralyovBuild is still in progress... Status page: https://farmer.golang.org/try?commit=95c8964e
Failed on linux-mips64-rtrk: https://storage.googleapis.com/go-build-log/95c8964e/linux-mips64-rtrk_1385efad.log
Other builds still in progress; subsequent failure notices suppressed until final report.Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test *exactly* your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed.
The requested legacy slowbots keep not completing on patch set 1. Removing Run-TryBot+1 vote since it's not adding new information.
They're broken due to https://github.com/golang/go/issues/77284 - it progressed sufficiently that this seems to be okay.
Would also be worth adding codegen to test/codegen/floats.go (probably need to stack on https://go-review.googlesource.com/c/go/+/733621 or wait for it to land though).
Absorb unnecessary conversion between float32 and float64
if both src and dst are 32 bit.
Ref: #733621I believe the correct syntax (for linking) is:
```suggestion
Ref: CL 733621
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Would also be worth adding codegen to test/codegen/floats.go (probably need to stack on https://go-review.googlesource.com/c/go/+/733621 or wait for it to land though).
I will add codegen in the later CL.
Absorb unnecessary conversion between float32 and float64
if both src and dst are 32 bit.
Done
Ref: #733621I believe the correct syntax (for linking) is:
```suggestion
Ref: CL 733621
```
Fix applied.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |