diff options
| author | Jorropo <jorropo.pgm@gmail.com> | 2025-07-04 09:26:38 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-07-24 13:49:07 -0700 |
| commit | f32cf8e4b025eee84aa3ec690966fa4e737a7522 (patch) | |
| tree | 10470a3f9270c7767fff7c68c8740fe65a47bf96 /test | |
| parent | d574856482859d259a95826dea404e648cbb8fef (diff) | |
| download | go-f32cf8e4b025eee84aa3ec690966fa4e737a7522.tar.xz | |
cmd/compile: learn transitive proofs for safe unsigned subs
I've split this into it's own CL to make git bisect more effective.
Change-Id: I436ff21a3e2362b3924de25a458534eb9947e013
Reviewed-on: https://go-review.googlesource.com/c/go/+/685821
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/prove.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/prove.go b/test/prove.go index a8a9ce1ce4..8daa812e76 100644 --- a/test/prove.go +++ b/test/prove.go @@ -2241,6 +2241,67 @@ func transitiveProofsThroughOverflowingSignedAddNegative(x, y, z int64) { } } +func transitiveProofsThroughNonOverflowingUnsignedSub(x, y, z uint64) { + x |= 0xfff + y &= 0xfff + + a := x - y + if a < z { + return + } + + if x < z { // ERROR "Disproved Less64U$" + return + } + if y < z { + return + } + if a == x { + return + } + if a == y { + return + } + + y |= 1 + a = x - y + if a == x { // ERROR "Disproved Eq64$" + return + } + if a == y { + return + } +} + +func transitiveProofsThroughOverflowingUnsignedSub(x, y, z uint64) { + a := x - y + if a < z { + return + } + + if x < z { + return + } + if y < z { + return + } + if a == x { + return + } + if a == y { + return + } + + y |= 1 + a = x - y + if a == x { + return + } + if a == y { + return + } +} + //go:noinline func useInt(a int) { } |
