aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/checkbce.go4
-rw-r--r--test/codegen/compare_and_branch.go12
-rw-r--r--test/loopbce.go33
3 files changed, 38 insertions, 11 deletions
diff --git a/test/checkbce.go b/test/checkbce.go
index 6a126099bc..ab31d95283 100644
--- a/test/checkbce.go
+++ b/test/checkbce.go
@@ -137,6 +137,10 @@ func g4(a [100]int) {
useInt(a[i+50])
// The following are out of bounds.
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
useInt(a[i-11]) // ERROR "Found IsInBounds$"
useInt(a[i+51]) // ERROR "Found IsInBounds$"
}
diff --git a/test/codegen/compare_and_branch.go b/test/codegen/compare_and_branch.go
index b3feef0eb7..479bd318be 100644
--- a/test/codegen/compare_and_branch.go
+++ b/test/codegen/compare_and_branch.go
@@ -35,12 +35,12 @@ func si64x8() {
}
// s390x:"CGIJ\t[$]2, R[0-9]+, [$]127, "
- for i := int64(0); i >= 128; i++ {
+ for i := int64(129); i >= 128; i-- {
dummy()
}
// s390x:"CGIJ\t[$]4, R[0-9]+, [$]-128, "
- for i := int64(0); i <= -129; i-- {
+ for i := int64(-130); i <= -129; i++ {
dummy()
}
}
@@ -71,7 +71,7 @@ func ui64x8() {
}
// s390x:"CLGIJ\t[$]2, R[0-9]+, [$]255, "
- for i := uint64(0); i >= 256; i-- {
+ for i := uint64(257); i >= 256; i-- {
dummy()
}
@@ -107,12 +107,12 @@ func si32x8() {
}
// s390x:"CIJ\t[$]2, R[0-9]+, [$]127, "
- for i := int32(0); i >= 128; i++ {
+ for i := int32(129); i >= 128; i-- {
dummy()
}
// s390x:"CIJ\t[$]4, R[0-9]+, [$]-128, "
- for i := int32(0); i <= -129; i-- {
+ for i := int32(-130); i <= -129; i++ {
dummy()
}
}
@@ -143,7 +143,7 @@ func ui32x8() {
}
// s390x:"CLIJ\t[$]2, R[0-9]+, [$]255, "
- for i := uint32(0); i >= 256; i-- {
+ for i := uint32(257); i >= 256; i-- {
dummy()
}
diff --git a/test/loopbce.go b/test/loopbce.go
index fcf0d8d90d..1119aaa65a 100644
--- a/test/loopbce.go
+++ b/test/loopbce.go
@@ -58,7 +58,7 @@ func f4(a [10]int) int {
func f5(a [10]int) int {
x := 0
for i := -10; i < len(a); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$"
- x += a[i]
+ x += a[i+10]
}
return x
}
@@ -66,7 +66,7 @@ func f5(a [10]int) int {
func f5_int32(a [10]int) int {
x := 0
for i := int32(-10); i < int32(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$"
- x += a[i]
+ x += a[i+10]
}
return x
}
@@ -74,7 +74,7 @@ func f5_int32(a [10]int) int {
func f5_int16(a [10]int) int {
x := 0
for i := int16(-10); i < int16(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$"
- x += a[i]
+ x += a[i+10]
}
return x
}
@@ -82,7 +82,7 @@ func f5_int16(a [10]int) int {
func f5_int8(a [10]int) int {
x := 0
for i := int8(-10); i < int8(len(a)); i += 2 { // ERROR "Induction variable: limits \[-10,8\], increment 2$"
- x += a[i]
+ x += a[i+10]
}
return x
}
@@ -201,6 +201,10 @@ func h2(a []byte) {
func k0(a [100]int) [100]int {
for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
a[i-11] = i
a[i-10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$"
a[i-5] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$"
@@ -214,6 +218,10 @@ func k0(a [100]int) [100]int {
func k1(a [100]int) [100]int {
for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
useSlice(a[:i-11])
useSlice(a[:i-10]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$"
useSlice(a[:i-5]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$"
@@ -229,6 +237,10 @@ func k1(a [100]int) [100]int {
func k2(a [100]int) [100]int {
for i := 10; i < 90; i++ { // ERROR "Induction variable: limits \[10,90\), increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
useSlice(a[i-11:])
useSlice(a[i-10:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$"
useSlice(a[i-5:]) // ERROR "(\([0-9]+\) )?Proved IsSliceInBounds$"
@@ -243,6 +255,10 @@ func k2(a [100]int) [100]int {
func k3(a [100]int) [100]int {
for i := -10; i < 90; i++ { // ERROR "Induction variable: limits \[-10,90\), increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
a[i+9] = i
a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$"
a[i+11] = i
@@ -252,6 +268,10 @@ func k3(a [100]int) [100]int {
func k3neg(a [100]int) [100]int {
for i := 89; i > -11; i-- { // ERROR "Induction variable: limits \(-11,89\], increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
a[i+9] = i
a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$"
a[i+11] = i
@@ -261,6 +281,10 @@ func k3neg(a [100]int) [100]int {
func k3neg2(a [100]int) [100]int {
for i := 89; i >= -10; i-- { // ERROR "Induction variable: limits \[-10,89\], increment 1$"
+ if a[0] == 0xdeadbeef {
+ // This is a trick to prohibit sccp to optimize out the following out of bound check
+ continue
+ }
a[i+9] = i
a[i+10] = i // ERROR "(\([0-9]+\) )?Proved IsInBounds$"
a[i+11] = i
@@ -411,7 +435,6 @@ func nobce3(a [100]int64) [100]int64 {
min := int64((-1) << 63)
max := int64((1 << 63) - 1)
for i := min; i < max; i++ { // ERROR "Induction variable: limits \[-9223372036854775808,9223372036854775807\), increment 1$"
- a[i] = i
}
return a
}