Skip to content

Commit

Permalink
[release-branch.go1.9] cmd/compile: add rules handling unsigned div/m…
Browse files Browse the repository at this point in the history
…od 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>
  • Loading branch information
cherrymui committed Aug 18, 2017
1 parent 65717b2 commit 5927854
Show file tree
Hide file tree
Showing 4 changed files with 724 additions and 1 deletion.
Loading

0 comments on commit 5927854

Please sign in to comment.