diff options
author | Alexandru Moșoi <mosoi@google.com> | 2016-04-01 15:09:19 +0200 |
---|---|---|
committer | Alexandru Moșoi <alexandru@mosoi.ro> | 2016-04-11 16:01:22 +0000 |
commit | 6c6089b3fdba9eb0cff863a03074dbac47c92f63 (patch) | |
tree | 8d4eacf7fc80504db1a2bf1468b3192060ce1dcd /test/checkbce.go | |
parent | 00681eec6aec03b8b2822c9220fba27c18923c01 (diff) | |
download | go-6c6089b3fdba9eb0cff863a03074dbac47c92f63.tar.gz go-6c6089b3fdba9eb0cff863a03074dbac47c92f63.zip |
cmd/compile: bce when max and limit are consts
Removes 49 more bound checks in make.bash. For example:
var a[100]int
for i := 0; i < 50; i++ {
use a[i+25]
}
Change-Id: I85e0130ee5d07f0ece9b17044bba1a2047414ce7
Reviewed-on: https://go-review.googlesource.com/21379
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Alexandru Moșoi <alexandru@mosoi.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test/checkbce.go')
-rw-r--r-- | test/checkbce.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/checkbce.go b/test/checkbce.go index 988375fcc7..fa0ea12803 100644 --- a/test/checkbce.go +++ b/test/checkbce.go @@ -57,7 +57,7 @@ func f6(a [32]int, b [64]int, i int) { useInt(b[uint64(i*0x07C4ACDD)>>58]) useInt(a[uint(i*0x07C4ACDD)>>59]) - // The following bounds should removed as they can overflow. + // The following bounds should not be removed because they can overflow. useInt(a[uint32(i*0x106297f105d0cc86)>>26]) // ERROR "Found IsInBounds$" useInt(b[uint64(i*0x106297f105d0cc86)>>57]) // ERROR "Found IsInBounds$" useInt(a[int32(i*0x106297f105d0cc86)>>26]) // ERROR "Found IsInBounds$" @@ -89,6 +89,19 @@ func g3(a []int) { } } +func g4(a [100]int) { + for i := 10; i < 50; i++ { + useInt(a[i-10]) + useInt(a[i]) + useInt(a[i+25]) + useInt(a[i+50]) + + // The following are out of bounds. + useInt(a[i-11]) // ERROR "Found IsInBounds$" + useInt(a[i+51]) // ERROR "Found IsInBounds$" + } +} + //go:noinline func useInt(a int) { } |