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, minU(a.umax, b.umax-1))
+ case OpDiv64u, OpDiv32u, OpDiv16u, OpDiv8u:
+ a := ft.limits[v.Args[0].ID]
+ b := ft.limits[v.Args[1].ID]
+ lim := noLimit
+ if b.umax > 0 {
+ lim = lim.unsignedMin(a.umin / b.umax)
+ }
+ if b.umin > 0 {
+ lim = lim.unsignedMax(a.umax / b.umin)
+ }
+ return ft.newLimit(v, lim)
case OpPhi:
// Compute the union of all the input phis.
return z
}
+func div64u(a, b uint64, ensureAllBranchesCouldHappen func() bool) uint64 {
+ a &= 0xffff
+ a |= 0xfff
+ b &= 0xff
+ b |= 0xf
+
+ z := a / b // ERROR "Proved Neq64$"
+
+ if ensureAllBranchesCouldHappen() && z > 0xffff/0xf { // ERROR "Disproved Less64U$"
+ return 42
+ }
+ if ensureAllBranchesCouldHappen() && z <= 0xffff/0xf { // ERROR "Proved Leq64U$"
+ return 1337
+ }
+ if ensureAllBranchesCouldHappen() && z < 0xfff/0xff { // ERROR "Disproved Less64U$"
+ return 42
+ }
+ if ensureAllBranchesCouldHappen() && z >= 0xfff/0xff { // ERROR "Proved Leq64U$"
+ return 42
+ }
+ return z
+}
+
//go:noinline
func useInt(a int) {
}