diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 1aab7e3eb77..39080a015e9 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -2885,9 +2885,9 @@ func simplifyBlock(sdom SparseTree, ft *factsTable, b *Block) { xl := ft.limits[x.ID] y := v.Args[1] 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) || - yl.umin == yl.umax && isPowerOfTwo(int64(yl.umin)) || + yl.umin == yl.umax && isUnsignedPowerOfTwo(yl.umin) || yl.min == yl.max && isPowerOfTwo(yl.min) { // 0,1 * a power of two is better done as a shift break diff --git a/test/prove.go b/test/prove.go index 1b50317fe3e..e04b510e170 100644 --- a/test/prove.go +++ b/test/prove.go @@ -2718,6 +2718,14 @@ func detectStringLenRelation(s string) bool { 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 func prove(x int) { }