[release-branch.go1.9] cmd/compile: add rules handling unsigned div/mod by constant 1<<63
Cherry-pick CL 56890. Normally 64-bit div/mod is turned into runtime calls on 32-bit arch, but the front end leaves power-of-two constant division and hopes the SSA backend turns into a shift or AND. The SSA rule is (Mod64u <t> n (Const64 [c])) && isPowerOfTwo(c) -> (And64 n (Const64 <t> [c-1])) But isPowerOfTwo returns true only for positive int64, which leaves out 1<<63 unhandled. Add a special case for 1<<63. Fixes #21517. Change-Id: Ic91f86fd5e035a8bb64b937c15cb1c38fec917d6 Reviewed-on: https://go-review.googlesource.com/57070 Run-TryBot: Cherry Zhang <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Showing
This diff is collapsed.
Please register or sign in to comment