]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: extend prove pass to handle constant comparisons
authorKeith Randall <khr@golang.org>
Wed, 23 Mar 2016 17:20:44 +0000 (10:20 -0700)
committerKeith Randall <khr@golang.org>
Thu, 31 Mar 2016 21:16:23 +0000 (21:16 +0000)
commit47c9e139aed3e6d24ee980828835fb03229272ff
tree8cfe337ec1b56cf4ae55df7aeb51559d8a058909
parentf5bd3556f51ce607daa0996bacd1d22563d65ea4
cmd/compile: extend prove pass to handle constant comparisons

Find comparisons to constants and propagate that information
down the dominator tree.  Use it to resolve other constant
comparisons on the same variable.

So if we know x >= 7, then a x > 4 condition must return true.

This change allows us to use "_ = b[7]" hints to eliminate bounds checks.

Fixes #14900

Change-Id: Idbf230bd5b7da43de3ecb48706e21cf01bf812f7
Reviewed-on: https://go-review.googlesource.com/21008
Reviewed-by: Alexandru Moșoi <alexandru@mosoi.ro>
src/cmd/compile/internal/ssa/prove.go
src/cmd/compile/internal/ssa/value.go
src/encoding/binary/binary.go
test/prove.go