aboutsummaryrefslogtreecommitdiff
path: root/test/checkbce.go
diff options
context:
space:
mode:
authorGiovanni Bajo <rasky@develer.com>2017-02-26 02:54:32 +0100
committerKeith Randall <khr@golang.org>2017-03-04 16:13:07 +0000
commit4fc45ae8794eaa84505629e82997b90503c89aa2 (patch)
tree4c7c0be07459b28f39dff2bdec243eb9f4de8ddc /test/checkbce.go
parent4a7cf960c38d72e9f0c6f00e46e013be2a35d56e (diff)
downloadgo-4fc45ae8794eaa84505629e82997b90503c89aa2.tar.gz
go-4fc45ae8794eaa84505629e82997b90503c89aa2.zip
cmd/compile: improve generic rules for BCE based on AND operations.
Match more patterns generated by the compiler where the index for a bound check is bounded through a AND operation, with different register sizes. These rules trigger a dozen of times in a bootstrap. Change-Id: Ic9fff16f21d08580f19a366c3ee1a372e58357d1 Reviewed-on: https://go-review.googlesource.com/37442 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/checkbce.go')
-rw-r--r--test/checkbce.go45
1 files changed, 38 insertions, 7 deletions
diff --git a/test/checkbce.go b/test/checkbce.go
index 4f9574d420..a4b0fe0d2a 100644
--- a/test/checkbce.go
+++ b/test/checkbce.go
@@ -13,10 +13,14 @@ func f0(a []int) {
}
func f1(a [256]int, i int) {
- useInt(a[i]) // ERROR "Found IsInBounds$"
- useInt(a[i%256]) // ERROR "Found IsInBounds$"
- useInt(a[i&255])
- useInt(a[i&17])
+ var j int
+ useInt(a[i]) // ERROR "Found IsInBounds$"
+ j = i % 256
+ useInt(a[j]) // ERROR "Found IsInBounds$"
+ j = i & 255
+ useInt(a[j])
+ j = i & 17
+ useInt(a[j])
if 4 <= i && i < len(a) {
useInt(a[i])
@@ -29,9 +33,36 @@ func f1(a [256]int, i int) {
func f2(a [256]int, i uint) {
useInt(a[i]) // ERROR "Found IsInBounds$"
- useInt(a[i%256])
- useInt(a[i&255])
- useInt(a[i&17])
+ j := i % 256
+ useInt(a[j])
+ j = i & 255
+ useInt(a[j])
+ j = i & 17
+ useInt(a[j])
+}
+
+func f2a(a [35]int, i uint8) {
+ useInt(a[i]) // ERROR "Found IsInBounds$"
+ j := i & 34
+ useInt(a[j])
+ j = i & 17
+ useInt(a[j])
+}
+
+func f2b(a [35]int, i uint16) {
+ useInt(a[i]) // ERROR "Found IsInBounds$"
+ j := i & 34
+ useInt(a[j])
+ j = i & 17
+ useInt(a[j])
+}
+
+func f2c(a [35]int, i uint32) {
+ useInt(a[i]) // ERROR "Found IsInBounds$"
+ j := i & 34
+ useInt(a[j])
+ j = i & 17
+ useInt(a[j])
}
func f3(a [256]int, i uint8) {