aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJorropo <jorropo.pgm@gmail.com>2024-08-14 21:25:08 +0200
committerKeith Randall <khr@golang.org>2024-09-03 21:12:00 +0000
commit4f2c0e5d0806a2f6fbe2d0704683d2b71d8191be (patch)
treef302367f5048839d8a8e0ae0d6aec72ee7ceb7c7 /test
parent68c431e89f2cb5422d53c65be988b15598a9c692 (diff)
downloadgo-4f2c0e5d0806a2f6fbe2d0704683d2b71d8191be.tar.xz
cmd/compile: compute Trunc's limits from argument's limits
Change-Id: I419faa781db085b98ea25008ca127d0317fb34e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/605695 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/prove.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/prove.go b/test/prove.go
index 28b950ce41..16f7b7de96 100644
--- a/test/prove.go
+++ b/test/prove.go
@@ -1586,6 +1586,26 @@ func div64s(a, b int64, ensureAllBranchesCouldHappen func() bool) int64 {
return z
}
+func trunc64to16(a uint64, ensureAllBranchesCouldHappen func() bool) uint16 {
+ a &= 0xfff
+ a |= 0xff
+
+ z := uint16(a)
+ if ensureAllBranchesCouldHappen() && z > 0xfff { // ERROR "Disproved Less16U$"
+ return 42
+ }
+ if ensureAllBranchesCouldHappen() && z <= 0xfff { // ERROR "Proved Leq16U$"
+ return 1337
+ }
+ if ensureAllBranchesCouldHappen() && z < 0xff { // ERROR "Disproved Less16U$"
+ return 42
+ }
+ if ensureAllBranchesCouldHappen() && z >= 0xff { // ERROR "Proved Leq16U$"
+ return 1337
+ }
+ return z
+}
+
//go:noinline
func useInt(a int) {
}