diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2019-04-20 11:09:34 -0700 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2019-04-20 19:34:03 +0000 |
| commit | 68d4b1265ec7915dccfccf6c0e32f9ab2d9c3a86 (patch) | |
| tree | ec4088bbe86f6c81e917f2db3a03e4784e14dd35 /test/codegen/mathbits.go | |
| parent | d23cba683e59f6092c1e3f676c8e83e7973f27dd (diff) | |
| download | go-68d4b1265ec7915dccfccf6c0e32f9ab2d9c3a86.tar.xz | |
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 <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/codegen/mathbits.go')
| -rw-r--r-- | test/codegen/mathbits.go | 5 |
1 files changed, 5 insertions, 0 deletions
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) +} |
