mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: use isUnsignedPowerOfTwo rather than isPowerOfTwo for unsigneds
Fixes #76688 Change-Id: Icb8dab54a5ce7d83b656d50d5ea605d2a62b96f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/726680 Auto-Submit: Jorropo <jorropo.pgm@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
2b62144069
commit
7b67b68a0d
2 changed files with 10 additions and 2 deletions
|
|
@ -2885,9 +2885,9 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) {
|
||||||
xl := ft.limits[x.ID]
|
xl := ft.limits[x.ID]
|
||||||
y := v.Args[1]
|
y := v.Args[1]
|
||||||
yl := ft.limits[y.ID]
|
yl := ft.limits[y.ID]
|
||||||
if xl.umin == xl.umax && isPowerOfTwo(int64(xl.umin)) ||
|
if xl.umin == xl.umax && isUnsignedPowerOfTwo(xl.umin) ||
|
||||||
xl.min == xl.max && isPowerOfTwo(xl.min) ||
|
xl.min == xl.max && isPowerOfTwo(xl.min) ||
|
||||||
yl.umin == yl.umax && isPowerOfTwo(int64(yl.umin)) ||
|
yl.umin == yl.umax && isUnsignedPowerOfTwo(yl.umin) ||
|
||||||
yl.min == yl.max && isPowerOfTwo(yl.min) {
|
yl.min == yl.max && isPowerOfTwo(yl.min) {
|
||||||
// 0,1 * a power of two is better done as a shift
|
// 0,1 * a power of two is better done as a shift
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -2718,6 +2718,14 @@ func detectStringLenRelation(s string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func issue76688(x, y uint64) uint64 {
|
||||||
|
if x > 1 || y != 1<<63 {
|
||||||
|
return 42
|
||||||
|
}
|
||||||
|
// We do not want to rewrite the multiply to a condselect here since opt can do a better job with a left shift.
|
||||||
|
return x * y
|
||||||
|
}
|
||||||
|
|
||||||
//go:noinline
|
//go:noinline
|
||||||
func prove(x int) {
|
func prove(x int) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue