From ebf7747dbe0204a930815200b3cbc63a09967bf9 Mon Sep 17 00:00:00 2001 From: "Paul E. Murphy" Date: Fri, 29 Mar 2024 16:11:36 -0500 Subject: cmd/internal/obj/ppc64: on Power10, use xxspltidp for float constants Any normal float32 constant can be generated by this instruction; use xxspltidp when possible. This prefixed instruction is much faster than the two instruction load sequence from the float32/float64 constant pool. Change-Id: Id751d9ffdae71463adbde66427b986f0b2ef74c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/575555 Reviewed-by: Than McIntosh Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Run-TryBot: Paul Murphy LUCI-TryBot-Result: Go LUCI Reviewed-by: Lynn Boger --- test/codegen/floats.go | 31 +++++++++++++++++++++++++++++++ test/codegen/math.go | 4 +++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/codegen/floats.go b/test/codegen/floats.go index d5c5475567..baa745bdee 100644 --- a/test/codegen/floats.go +++ b/test/codegen/floats.go @@ -196,3 +196,34 @@ func Float32Max(a, b float32) float32 { // ppc64/power10:"XSMAXJDP" return max(a, b) } + +// ------------------------ // +// Constant Optimizations // +// ------------------------ // + +func Float32Constant() float32 { + // ppc64x/power8:"FMOVS\t[$]f32\\.42440000\\(SB\\)" + // ppc64x/power9:"FMOVS\t[$]f32\\.42440000\\(SB\\)" + // ppc64x/power10:"XXSPLTIDP\t[$]1111752704," + return 49.0 +} + +func Float64Constant() float64 { + // ppc64x/power8:"FMOVD\t[$]f64\\.4048800000000000\\(SB\\)" + // ppc64x/power9:"FMOVD\t[$]f64\\.4048800000000000\\(SB\\)" + // ppc64x/power10:"XXSPLTIDP\t[$]1111752704," + return 49.0 +} + +func Float32DenormalConstant() float32 { + // ppc64x:"FMOVS\t[$]f32\\.00400000\\(SB\\)" + return 0x1p-127 +} + +// A float64 constant which can be exactly represented as a +// denormal float32 value. On ppc64x, denormal values cannot +// be used with XXSPLTIDP. +func Float64DenormalFloat32Constant() float64 { + // ppc64x:"FMOVD\t[$]f64\\.3800000000000000\\(SB\\)" + return 0x1p-127 +} diff --git a/test/codegen/math.go b/test/codegen/math.go index 331ebbe609..eb6e927dec 100644 --- a/test/codegen/math.go +++ b/test/codegen/math.go @@ -204,7 +204,9 @@ func constantCheck32() bool { func constantConvert32(x float32) float32 { // amd64:"MOVSS\t[$]f32.3f800000\\(SB\\)" // s390x:"FMOVS\t[$]f32.3f800000\\(SB\\)" - // ppc64x:"FMOVS\t[$]f32.3f800000\\(SB\\)" + // ppc64x/power8:"FMOVS\t[$]f32.3f800000\\(SB\\)" + // ppc64x/power9:"FMOVS\t[$]f32.3f800000\\(SB\\)" + // ppc64x/power10:"XXSPLTIDP\t[$]1065353216, VS0" // arm64:"FMOVS\t[$]\\(1.0\\)" if x > math.Float32frombits(0x3f800000) { return -x -- cgit v1.2.3-54-g00ecf