You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes.
What did you do?
When dividing by constant (e.g. x/5), Go uses multiplication by a magic constant, instead of using DIVQ instruction. However, bits.Div64 apparently still uses that instruction.
What did you expect to see?
That the following two functions would compile roughly to same code, i.e. there would be no DIVQ.
func Div(x uint64) (uint64, uint64) {
z := x
y := x/5
z -= y
return y, z
}
func Div(x uint64) (uint64, uint64) {
y, z := bits.Div64(0, x, 5)
return y, z
}
My CL handles Div64(0, lo, y). It doesn't handle Div64(hi, lo, 5). You can imagine wanting to use magic division techniques for 128 bit division by a constant.
Sorry, I should have distinguished Div64(0, lo, y) and Div64(hi, lo, y). While I agree a general case is useful as well, I originally meant the former. I noticed the discrepancy between the particular case of bits.Div64 and plain /, which the CL fixes.
Perhaps this issue could be used to track the eventual development for the general case, somewhat in sync with #30282.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What did you do?
When dividing by constant (e.g.
x/5
), Go uses multiplication by a magic constant, instead of usingDIVQ
instruction. However,bits.Div64
apparently still uses that instruction.What did you expect to see?
That the following two functions would compile roughly to same code, i.e. there would be no
DIVQ
.What did you see instead?
First function compiles to:
The second function includes
DIVQ
.The text was updated successfully, but these errors were encountered: