-// +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.
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])
}
}
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$"
}