From 68d4b1265ec7915dccfccf6c0e32f9ab2d9c3a86 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Sat, 20 Apr 2019 11:09:34 -0700 Subject: cmd/compile: reduce bits.Div64(0, lo, y) to 64 bit division With this change, these two functions generate identical code: func f(x uint64) (uint64, uint64) { return bits.Div64(0, x, 5) } func g(x uint64) (uint64, uint64) { return x / 5, x % 5 } Updates #31582 Change-Id: Ia96c2e67f8af5dd985823afee5f155608c04a4b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/173197 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- test/codegen/mathbits.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/codegen/mathbits.go') diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go index b6992c6bb4..6676c69188 100644 --- a/test/codegen/mathbits.go +++ b/test/codegen/mathbits.go @@ -538,3 +538,8 @@ func Div64(hi, lo, x uint64) (q, r uint64) { // amd64:"DIVQ" return bits.Div64(hi, lo, x) } + +func Div64degenerate(x uint64) (q, r uint64) { + // amd64:-"DIVQ" + return bits.Div64(0, x, 5) +} -- cgit v1.3