1
0
mirror of https://github.com/golang/go synced 2024-09-23 13:10:13 -06:00

cmd/compile: fix off-by-one error in prove pass

I think I introduced #68809 when rewriting the prove pass, by
introducing an off-by-one error here:
https://go-review.googlesource.com/c/go/+/599096/5/src/cmd/compile/internal/ssa/prove.go
lines 872-874.
The min++ is already handled in one of the two following cases with
the (r&eq==0) condition. Move the min++ to just the other case.

Fixes #68809

Change-Id: Iffae99e29219c94aaf584cd7ae247289fa604a00
Reviewed-on: https://go-review.googlesource.com/c/go/+/604100
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Keith Randall 2024-08-09 10:59:43 -07:00
parent 1cf6e31f0d
commit f259e4c916
2 changed files with 22 additions and 3 deletions

View File

@ -1059,9 +1059,6 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
// We know that either x>min OR x<=max. factsTable cannot record OR conditions,
// so let's see if we can already prove that one of them is false, in which case
// the other must be true
if r == gt {
min++
}
l := ft.limits[x.ID]
if l.max <= min {
if r&eq == 0 || l.max < min {
@ -1070,6 +1067,9 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
}
} else if l.min > max {
// x<=max is impossible, so it must be x>min
if r == gt {
min++
}
ft.signedMin(x, min)
}
}

View File

@ -0,0 +1,19 @@
// run
// Copyright 2024 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.
package main
func main() {
cnt := 0
for i := 1; i <= 11; i++ {
if i-6 > 4 {
cnt++
}
}
if cnt != 1 {
panic("bad")
}
}