cmd/compile: teach prove about bitwise OR operation

Fixes #45928.

Change-Id: Ifbb0effbca4ab7c0eb56069fee40edb564553c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/410336
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Wayne Zuo 2022-06-05 13:22:29 +08:00 committed by Daniel Martí
parent d2e0587f77
commit 3680b5e9c4
2 changed files with 8 additions and 0 deletions

View File

@ -842,6 +842,9 @@ func prove(f *Func) {
case OpAnd64, OpAnd32, OpAnd16, OpAnd8:
ft.update(b, v, v.Args[1], unsigned, lt|eq)
ft.update(b, v, v.Args[0], unsigned, lt|eq)
case OpOr64, OpOr32, OpOr16, OpOr8:
ft.update(b, v, v.Args[1], unsigned, gt|eq)
ft.update(b, v, v.Args[0], unsigned, gt|eq)
}
}
}

View File

@ -1053,6 +1053,11 @@ func issue51622(b []byte) int {
return 0
}
func issue45928(x int) {
combinedFrac := (x) / (x | (1 << 31)) // ERROR "Proved Neq64$"
useInt(combinedFrac)
}
//go:noinline
func useInt(a int) {
}