From: Jorropo Date: Sat, 25 Oct 2025 16:38:23 +0000 (+0200) Subject: cmd/compile: remove 68857 ModU flowLimit workaround in prove X-Git-Tag: go1.26rc1~457 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=2ce5aab79e;p=gostls13.git cmd/compile: remove 68857 ModU flowLimit workaround in prove We can know this is correct because all the testcases added by CL 605156 are still passing. Partial revert of CL 605156 (everything but the testcases). Change-Id: I5d8daadb4cb35a9de29daaabc22baee642511fe0 Reviewed-on: https://go-review.googlesource.com/c/go/+/714941 Reviewed-by: Keith Randall Reviewed-by: Michael Knyszek Auto-Submit: Jorropo Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ssa/prove.go b/src/cmd/compile/internal/ssa/prove.go index d448f6e7fc..5010fa3a6d 100644 --- a/src/cmd/compile/internal/ssa/prove.go +++ b/src/cmd/compile/internal/ssa/prove.go @@ -1962,19 +1962,6 @@ func (ft *factsTable) flowLimit(v *Value) bool { b := ft.limits[v.Args[1].ID] bitsize := uint(v.Type.Size()) * 8 return ft.newLimit(v, a.mul(b.exp2(bitsize), bitsize)) - case OpMod64, OpMod32, OpMod16, OpMod8: - a := ft.limits[v.Args[0].ID] - b := ft.limits[v.Args[1].ID] - if !(a.nonnegative() && b.nonnegative()) { - // TODO: we could handle signed limits but I didn't bother. - break - } - fallthrough - case OpMod64u, OpMod32u, OpMod16u, OpMod8u: - a := ft.limits[v.Args[0].ID] - b := ft.limits[v.Args[1].ID] - // Underflow in the arithmetic below is ok, it gives to MaxUint64 which does nothing to the limit. - return ft.unsignedMax(v, min(a.umax, b.umax-1)) case OpDiv64, OpDiv32, OpDiv16, OpDiv8: a := ft.limits[v.Args[0].ID] b := ft.limits[v.Args[1].ID] @@ -2484,6 +2471,14 @@ func addLocalFacts(ft *factsTable, b *Block) { OpRsh32Ux64, OpRsh32Ux32, OpRsh32Ux16, OpRsh32Ux8, OpRsh64Ux64, OpRsh64Ux32, OpRsh64Ux16, OpRsh64Ux8: ft.update(b, v, v.Args[0], unsigned, lt|eq) + case OpMod64, OpMod32, OpMod16, OpMod8: + a := ft.limits[v.Args[0].ID] + b := ft.limits[v.Args[1].ID] + if !(a.nonnegative() && b.nonnegative()) { + // TODO: we could handle signed limits but I didn't bother. + break + } + fallthrough case OpMod64u, OpMod32u, OpMod16u, OpMod8u: ft.update(b, v, v.Args[0], unsigned, lt|eq) // Note: we have to be careful that this doesn't imply