]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove 68857 ModU flowLimit workaround in prove
authorJorropo <jorropo.pgm@gmail.com>
Sat, 25 Oct 2025 16:38:23 +0000 (18:38 +0200)
committerGopher Robot <gobot@golang.org>
Tue, 28 Oct 2025 02:06:18 +0000 (19:06 -0700)
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 <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/ssa/prove.go

index d448f6e7fc95d112a5a523018eb344dc96dc7c97..5010fa3a6d352997b381f5a21cf22ea771243683 100644 (file)
@@ -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