]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: implement shifts by signed amounts
authorKeith Randall <keithr@alum.mit.edu>
Sun, 20 Jan 2019 18:52:11 +0000 (10:52 -0800)
committerKeith Randall <khr@golang.org>
Fri, 15 Feb 2019 23:13:09 +0000 (23:13 +0000)
commit585c9e8412540b10be5154d019828a1a27f7b4c4
tree95ef6dde3e463fd169a69eed0cc20b3e3b2d2b19
parente1acd854f754f496be341211e9deee53fc7e3404
cmd/compile: implement shifts by signed amounts

Allow shifts by signed amounts. Panic if the shift amount is negative.

TODO: We end up doing two compares per shift, see Ian's comment
https://github.com/golang/go/issues/19113#issuecomment-443241799 that
we could do it with a single comparison in the normal case.

The prove pass mostly handles this code well. For instance, it removes the
<0 check for cases like this:
    if s >= 0 { _ = x << s }
    _ = x << len(a)

This case isn't handled well yet:
    _ = x << (y & 0xf)
I'll do followon CLs for unhandled cases as needed.

Update #19113

R=go1.13

Change-Id: I839a5933d94b54ab04deb9dd5149f32c51c90fa1
Reviewed-on: https://go-review.googlesource.com/c/158719
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/builtin.go
src/cmd/compile/internal/gc/builtin/runtime.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/ssa/rewrite.go
src/cmd/internal/obj/x86/obj6.go
src/runtime/panic.go
test/fixedbugs/bug073.go
test/fixedbugs/issue19113.go [new file with mode: 0644]