test/codegen: add codegen checks for float32/float64 conversions optimizations

Updates #75463

Change-Id: Iec51bdedd5a29bbb81ac553ad7e22403e1715ee3
Reviewed-on: https://go-review.googlesource.com/c/go/+/757300
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Julian Zhu
2026-03-20 19:09:22 +08:00
committed by Gopher Robot
parent cfb67d0871
commit 07f0c2074c

View File

@@ -281,26 +281,53 @@ func Float64ConstantStore(p *float64) {
}
func WideCeilNarrow(x float32) float32 {
// amd64/v3:"ROUNDSS"
// arm64:"FRINTPS"
// wasm:"F32Ceil"
// amd64/v3:"ROUNDSS" -"CVTSS2SD" -"CVTSD2SS"
// arm64:"FRINTPS" -"FCVTSD" -"FCVTDS"
// wasm:"F32Ceil" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.Ceil(float64(x)))
}
func WideTruncNarrow(x float32) float32 {
// amd64/v3:"ROUNDSS"
// arm64:"FRINTZS"
// wasm:"F32Trunc"
// amd64/v3:"ROUNDSS" -"CVTSS2SD" -"CVTSD2SS"
// arm64:"FRINTZS" -"FCVTSD" -"FCVTDS"
// wasm:"F32Trunc" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.Trunc(float64(x)))
}
func WideFloorNarrow(x float32) float32 {
// amd64/v3:"ROUNDSS" -"CVTSS2SD" -"CVTSD2SS"
// arm64:"FRINTMS" -"FCVTSD" -"FCVTDS"
// wasm:"F32Floor" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.Floor(float64(x)))
}
func WideRoundNarrow(x float32) float32 {
// arm64:"FRINTAS" -"FCVTSD" -"FCVTDS"
return float32(math.Round(float64(x)))
}
func WideRoundToEvenNarrow(x float32) float32 {
// amd64/v3:"ROUNDSS" -"CVTSS2SD" -"CVTSD2SS"
// arm64:"FRINTNS" -"FCVTSD" -"FCVTDS"
// wasm:"F32Nearest" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.RoundToEven(float64(x)))
}
func WideSqrtNarrow(x float32) float32 {
// arm64:"FSQRTS" -"FCVTSD" -"FCVTDS"
// loong64:"SQRTF" -"MOVFD" -"MOVDF"
// mips64:"SQRTF" -"MOVFD" -"MOVDF"
// riscv64:"FSQRTS" -"FCVTDS" -"FCVTSD"
// wasm:"F32Sqrt" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.Sqrt(float64(x)))
}
func WideAbsNarrow(x float32) float32 {
// arm64:"FABSS" -"FCVTSD" -"FCVTDS"
// loong64:"ABSF" -"MOVFD" -"MOVDF"
// mips64:"ABSF" -"MOVFD" -"MOVDF"
// riscv64:"FABSS" -"FCVTDS" -"FCVTSD"
// wasm:"F32Abs" -"F64PromoteF32" -"F32DemoteF64"
return float32(math.Abs(float64(x)))
}