From: Jorropo Date: Fri, 9 Aug 2024 14:35:46 +0000 (+0200) Subject: cmd/compile: compute OR's maximum limits from argument's limits X-Git-Tag: go1.24rc1~1059 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=57df33814afc02bda314abea28ee8a3dc997505c;p=gostls13.git cmd/compile: compute OR's maximum limits from argument's limits Change-Id: I6902c405cab7bd573f6a721a6ca7c783713ea39a Reviewed-on: https://go-review.googlesource.com/c/go/+/604456 Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: David Chase Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index 5195a48608..807f198787 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -1698,10 +1698,12 @@ func (ft *factsTable) flowLimit(v *Value) bool { b := ft.limits[v.Args[1].ID] return ft.unsignedMax(v, minU(a.umax, b.umax)) case OpOr64, OpOr32, OpOr16, OpOr8: - // OR can only make the value bigger. + // OR can only make the value bigger and can't flip bits proved to be zero in both inputs. a := ft.limits[v.Args[0].ID] b := ft.limits[v.Args[1].ID] - return ft.unsignedMin(v, maxU(a.umin, b.umin)) + return ft.unsignedMinMax(v, + maxU(a.umin, b.umin), + 1< 0xfff { // ERROR "Disproved Less64U$" + return 42 + } + } else { + if z <= 0xfff { // ERROR "Proved Leq64U$" + return 1337 + } + } + return int(z) +} + //go:noinline func useInt(a int) { }