mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
cmd/compile: upgrade prove pass to know results of math/bits ops are nonnegative
Fixes #51963 Change-Id: Ib9e0521222e6fc41e787f3150b254e058a19addc Reviewed-on: https://go-review.googlesource.com/c/go/+/396036 Trust: Keith Randall <khr@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jakub Ciolek <jakub@ciolek.dev> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Eric Fang <eric.fang@arm.com>
This commit is contained in:
parent
7d3b64a2e3
commit
3bd8c78575
@ -824,6 +824,9 @@ func prove(f *Func) {
|
||||
}
|
||||
lensVars[b] = append(lensVars[b], v)
|
||||
}
|
||||
case OpCtz64, OpCtz32, OpCtz16, OpCtz8, OpBitLen64, OpBitLen32, OpBitLen16, OpBitLen8:
|
||||
ft.update(b, v, ft.zero, signed, gt|eq)
|
||||
// TODO: we could also do <= 64/32/16/8, if that helped.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1372,7 +1375,9 @@ func isNonNegative(v *Value) bool {
|
||||
case OpStringLen, OpSliceLen, OpSliceCap,
|
||||
OpZeroExt8to64, OpZeroExt16to64, OpZeroExt32to64,
|
||||
OpZeroExt8to32, OpZeroExt16to32, OpZeroExt8to16,
|
||||
OpCtz64, OpCtz32, OpCtz16, OpCtz8:
|
||||
OpCtz64, OpCtz32, OpCtz16, OpCtz8,
|
||||
OpCtz64NonZero, OpCtz32NonZero, OpCtz16NonZero, OpCtz8NonZero,
|
||||
OpBitLen64, OpBitLen32, OpBitLen16, OpBitLen8:
|
||||
return true
|
||||
|
||||
case OpRsh64Ux64, OpRsh32Ux64:
|
||||
|
Loading…
Reference in New Issue
Block a user