]> Cypherpunks repositories - gostls13.git/commit
cmd/compile,math: remove all sqrt assembly code
authorWayne Zuo <wdvxdr@golangcn.org>
Wed, 3 Aug 2022 15:31:29 +0000 (23:31 +0800)
committerKeith Randall <khr@golang.org>
Mon, 15 Aug 2022 17:07:57 +0000 (17:07 +0000)
commitc8000a18d688f65ad229c48a0e8a82435943eb6a
tree165666187ec0f7d971d03233a549911fe734a642
parent09932f95f5619f44fa874c780dbbddc073be990a
cmd/compile,math: remove all sqrt assembly code

This CL make math.sqrt an intrinsic function, math.Sqrt is not affected
since compiler can inline it. With this change, we can remove all assembly
code for math.Sqrt that aims to speed up indirect call. The go compiler can
generate same or faster code (with regabi) for indirect call.

Benchmark on amd64:
name                 old time/op  new time/op  delta
SqrtIndirect         2.60ns ± 3%  1.03ns ± 4%  -60.24%  (p=0.000 n=10+10)
SqrtLatency          3.40ns ± 1%  3.32ns ± 1%   -2.26%  (p=0.000 n=10+8)
SqrtIndirectLatency  6.09ns ± 0%  3.31ns ± 0%  -45.67%  (p=0.000 n=10+10)
SqrtGoLatency        36.1ns ± 6%  34.6ns ± 1%     ~     (p=0.101 n=10+10)
SqrtPrime            2.53µs ± 2%  2.55µs ± 6%     ~     (p=0.398 n=9+9)

Change-Id: If4be0f242c1d9d4feca7d269fc9cd6e6066f163d
Reviewed-on: https://go-review.googlesource.com/c/go/+/421074
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
13 files changed:
src/cmd/compile/internal/ssagen/ssa.go
src/math/sqrt.go
src/math/sqrt_386.s [deleted file]
src/math/sqrt_amd64.s [deleted file]
src/math/sqrt_arm.s [deleted file]
src/math/sqrt_arm64.s [deleted file]
src/math/sqrt_asm.go [deleted file]
src/math/sqrt_mipsx.s [deleted file]
src/math/sqrt_noasm.go [deleted file]
src/math/sqrt_ppc64x.s [deleted file]
src/math/sqrt_riscv64.s [deleted file]
src/math/sqrt_s390x.s [deleted file]
src/math/sqrt_wasm.s [deleted file]