aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/mathbits.go
diff options
context:
space:
mode:
authorBrian Kessler <brian.m.kessler@gmail.com>2018-10-23 20:54:56 -0600
committerKeith Randall <khr@golang.org>2018-11-27 05:04:25 +0000
commit319787a528284aefe23424056a19bda71f7cc2b1 (patch)
tree999010b57fa235c0f78489bb1a8ed972176921e7 /test/codegen/mathbits.go
parentead5d1e316873a63471de31f3d70f97aeb7969f5 (diff)
downloadgo-319787a528284aefe23424056a19bda71f7cc2b1.tar.xz
cmd/compile: intrinsify math/bits.Div on amd64
Note that the intrinsic implementation panics separately for overflow and divide by zero, which matches the behavior of the pure go implementation. There is a modest performance improvement after intrinsic implementation. name old time/op new time/op delta Div-4 53.0ns ± 1% 47.0ns ± 0% -11.28% (p=0.008 n=5+5) Div32-4 18.4ns ± 0% 18.5ns ± 1% ~ (p=0.444 n=5+5) Div64-4 53.3ns ± 0% 47.5ns ± 4% -10.77% (p=0.008 n=5+5) Updates #28273 Change-Id: Ic1688ecc0964acace2e91bf44ef16f5fb6b6bc82 Reviewed-on: https://go-review.googlesource.com/c/144378 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen/mathbits.go')
-rw-r--r--test/codegen/mathbits.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go
index 85d5bdea33..44ab2c02b7 100644
--- a/test/codegen/mathbits.go
+++ b/test/codegen/mathbits.go
@@ -465,3 +465,17 @@ func Mul64(x, y uint64) (hi, lo uint64) {
// ppc64le:"MULHDU","MULLD"
return bits.Mul64(x, y)
}
+
+// --------------- //
+// bits.Div* //
+// --------------- //
+
+func Div(hi, lo, x uint) (q, r uint) {
+ // amd64:"DIVQ"
+ return bits.Div(hi, lo, x)
+}
+
+func Div64(hi, lo, x uint64) (q, r uint64) {
+ // amd64:"DIVQ"
+ return bits.Div64(hi, lo, x)
+}