diff options
| author | Julian Zhu <jz531210@gmail.com> | 2026-03-20 19:09:22 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-23 07:33:12 -0700 |
| commit | 07f0c2074c257e7f89a52152f451c66e7f762481 (patch) | |
| tree | ead6cbf64bb451be04fb32196dcf7035004557bd /test/codegen | |
| parent | cfb67d08712c64308ccaa13870e119d517743271 (diff) | |
| download | go-07f0c2074c257e7f89a52152f451c66e7f762481.tar.xz | |
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>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/floats.go | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/test/codegen/floats.go b/test/codegen/floats.go index 25483c9f15..21cfa1d590 100644 --- a/test/codegen/floats.go +++ b/test/codegen/floats.go @@ -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))) } |
