]> Cypherpunks.ru repositories - gostls13.git/blobdiff - test/checkbce.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / checkbce.go
index 0a2842f10c0b8dcf1dee72a7bdc2117989bdc1fb..71acfb71ac17d46ec08acde3f0d878f40c8cec65 100644 (file)
@@ -1,6 +1,7 @@
-// +build amd64
 // errorcheck -0 -d=ssa/check_bce/debug=3
 
+//go:build amd64 && !gcflags_noopt
+
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
@@ -33,9 +34,7 @@ func f1(a [256]int, i int) {
 
        if 4 <= i && i < len(a) {
                useInt(a[i])
-               useInt(a[i-1]) // ERROR "Found IsInBounds$"
-               // TODO: 'if 4 <= i && i < len(a)' gets rewritten to 'if uint(i - 4) < 256 - 4',
-               // which the bounds checker cannot yet use to infer that the next line doesn't need a bounds check.
+               useInt(a[i-1])
                useInt(a[i-4])
        }
 }
@@ -139,6 +138,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$"
        }