mirror of
https://github.com/golang/go
synced 2024-11-26 11:48:03 -07:00
cmd/compile: in prove, infer unsigned relations while branching
When a branch is followed, we apply the relation as described in the domain relation table. In case the relation is in the positive domain, we can also infer an unsigned relation if, by that point, we know that both operands are non-negative. Fixes #20393 Change-Id: Ieaf0c81558b36d96616abae3eb834c788dd278d5 Reviewed-on: https://go-review.googlesource.com/100278 Run-TryBot: Giovanni Bajo <rasky@develer.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Giovanni Bajo <rasky@develer.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
5c40210987
commit
29162ec9a7
@ -704,6 +704,9 @@ func addBranchRestrictions(ft *factsTable, b *Block, br branch) {
|
|||||||
// When we branched from parent we learned a new set of
|
// When we branched from parent we learned a new set of
|
||||||
// restrictions. Update the factsTable accordingly.
|
// restrictions. Update the factsTable accordingly.
|
||||||
d := tr.d
|
d := tr.d
|
||||||
|
if d == signed && ft.isNonNegative(c.Args[0]) && ft.isNonNegative(c.Args[1]) {
|
||||||
|
d |= unsigned
|
||||||
|
}
|
||||||
switch br {
|
switch br {
|
||||||
case negative:
|
case negative:
|
||||||
switch b.Control.Op { // Special cases
|
switch b.Control.Op { // Special cases
|
||||||
|
@ -605,6 +605,15 @@ func trans2(a, b []int, i int) {
|
|||||||
_ = b[i] // ERROR "Proved IsInBounds$"
|
_ = b[i] // ERROR "Proved IsInBounds$"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trans3(a, b []int, i int) {
|
||||||
|
if len(a) > len(b) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = a[i]
|
||||||
|
_ = b[i] // ERROR "Proved IsInBounds$"
|
||||||
|
}
|
||||||
|
|
||||||
//go:noinline
|
//go:noinline
|
||||||
func useInt(a int) {
|
func useInt(a int) {
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user