]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: in prove, complete support for OpIsInBounds/OpIsSliceInBounds
authorGiovanni Bajo <rasky@develer.com>
Tue, 3 Apr 2018 16:58:01 +0000 (18:58 +0200)
committerGiovanni Bajo <rasky@develer.com>
Tue, 3 Apr 2018 20:25:34 +0000 (20:25 +0000)
commitac43de3ae5027f61e6b028c806f6b83f80ee5d3b
treec3d475d6f15a36e856a2d7353bcbec0282be5e1b
parentb846edfd5979d1cf53d55ea8fd6e4bbcfefb2e75
cmd/compile: in prove, complete support for OpIsInBounds/OpIsSliceInBounds

The logic in addBranchRestrictions didn't allow to correctly
model OpIs(Slice)Bound for signed domain, and it was also partly
implemented within addRestrictions.

Thanks to the previous changes, it is now possible to handle
the negative conditions correctly, so that we can learn
both signed/LT + unsigned/LT on the positive side, and
signed/GE + unsigned/GE on the negative side (but only if
the index can be proved to be non-negative).

This is able to prove ~50 more slice accesses in std+cmd.

Change-Id: I9858080dc03b16f85993a55983dbc4b00f8491b0
Reviewed-on: https://go-review.googlesource.com/104037
Run-TryBot: Giovanni Bajo <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/compile/internal/ssa/prove.go
test/prove.go