aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorMeng Zhuo <mengzhuo@iscas.ac.cn>2026-01-06 11:24:49 +0800
committerMeng Zhuo <mengzhuo@iscas.ac.cn>2026-03-16 17:15:04 -0700
commitf3966c1ada0a0ddaea873f979ee9165649eb11b7 (patch)
treeaae58d3fa111762fe45c1d06122ffc45b898fdd2 /test/codegen
parente7add86f163612d09c4c2ba2b80a4fc6eadf94bf (diff)
downloadgo-f3966c1ada0a0ddaea873f979ee9165649eb11b7.tar.xz
cmd/compile: (riscv64) optimize float32(abs|sqrt64(float64(x)))
Absorb unnecessary conversion between float32 and float64 if both src and dst are 32 bit. Updates #75463 Change-Id: Ia71941223b5cca3fea66b559da7b8f916e63feaf Reviewed-on: https://go-review.googlesource.com/c/go/+/733621 Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Julian Zhu <jz531210@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/floats.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/floats.go b/test/codegen/floats.go
index 3f27e54751..25483c9f15 100644
--- a/test/codegen/floats.go
+++ b/test/codegen/floats.go
@@ -294,6 +294,16 @@ func WideTruncNarrow(x float32) float32 {
return float32(math.Trunc(float64(x)))
}
+func WideSqrtNarrow(x float32) float32 {
+ // riscv64:"FSQRTS" -"FCVTDS" -"FCVTSD"
+ return float32(math.Sqrt(float64(x)))
+}
+
+func WideAbsNarrow(x float32) float32 {
+ // riscv64:"FABSS" -"FCVTDS" -"FCVTSD"
+ return float32(math.Abs(float64(x)))
+}
+
func WideCopysignNarrow(x, y float32) float32 {
// wasm:"F32Copysign"
return float32(math.Copysign(float64(x), float64(y)))