From f66db499769002f1f804f52234b7c3e5917bbad6 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Wed, 12 Jun 2024 18:25:55 -0700 Subject: cmd/compile: store constant floats using integer constants x86 is better at storing constant ints than constant floats. (It uses a constant directly in the instruction stream, instead of loading it from a constant global memory.) Noticed as part of #67957 Change-Id: I9b7b586ad8e0fe9ce245324f020e9526f82b209d Reviewed-on: https://go-review.googlesource.com/c/go/+/592596 LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Cherry Mui --- test/codegen/floats.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/floats.go b/test/codegen/floats.go index baa745bdee..d38df1cacb 100644 --- a/test/codegen/floats.go +++ b/test/codegen/floats.go @@ -227,3 +227,12 @@ func Float64DenormalFloat32Constant() float64 { // ppc64x:"FMOVD\t[$]f64\\.3800000000000000\\(SB\\)" return 0x1p-127 } + +func Float64ConstantStore(p *float64) { + // amd64: "MOVQ\t[$]4617801906721357038" + *p = 5.432 +} +func Float32ConstantStore(p *float32) { + // amd64: "MOVL\t[$]1085133554" + *p = 5.432 +} -- cgit v1.3-5-g9baa