0
1
mirror of https://github.com/golang/go synced 2025-11-04 00:58:42 +00:00
Files
Russ Cox 235b4e729d cmd/compile/internal/ssa: model right shift more precisely
Prove currently checks for 0 sign bit extraction (x>>63) at the
end of the pass, but it is more general and more useful
(and not really more work) to model right shift during
value range tracking. This handles sign bit extraction (both 0 and -1)
but also makes the value ranges available for proving bounds checks.

'go build -a -gcflags=-d=ssa/prove/debug=1 std'
finds 105 new things to prove.
https://gist.github.com/rsc/8ac41176e53ed9c2f1a664fc668e8336

For example, the compiler now recognizes that this code in
strconv does not need to check the second shift for being ≥ 64.

	msb := xHi >> 63
	retMantissa := xHi >> (msb + 38)

nor does this code in regexp:

	return b < utf8.RuneSelf && specialBytes[b%16]&(1<<(b/16)) != 0

This code in math no longer has a bounds check on the first index:

	if 0 <= n && n <= 308 {
		return pow10postab32[uint(n)/32] * pow10tab[uint(n)%32]
	}

The diff shows one "lost" proof in ycbcr.go but it's not really lost:
the expression was folded to a constant instead, and that only shows
up with debug=2. A diff of that output is at
https://gist.github.com/rsc/9139ed46c6019ae007f5a1ba4bb3250f

Change-Id: I84087311e0a303f00e2820d957a6f8b29ee22519
Reviewed-on: https://go-review.googlesource.com/c/go/+/716140
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-10-30 09:17:59 -07:00
..
2025-10-29 11:00:23 -07:00
2025-10-29 11:00:23 -07:00
2024-03-25 19:21:35 +00:00
2025-10-29 11:00:23 -07:00
2012-11-08 09:04:27 -08:00
2012-09-10 13:03:07 -07:00
2023-01-31 19:43:07 +00:00
2015-01-29 13:07:30 +00:00
2012-07-01 21:59:50 +04:00
2015-07-11 14:36:33 +00:00
2015-07-11 14:36:33 +00:00
2023-04-11 20:56:32 +00:00
2025-10-29 11:00:23 -07:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2012-02-19 14:28:53 +11:00
2025-10-29 11:00:23 -07:00
2019-09-08 17:28:20 +00:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2012-02-23 18:47:26 +11:00
2020-11-28 02:31:54 +00:00
2019-11-01 20:13:05 +00:00
2025-07-30 11:47:14 -07:00
2024-04-04 14:29:45 +00:00
2012-02-23 18:47:26 +11:00
2013-02-11 18:20:52 -05:00
2012-02-24 10:30:39 +11:00
2025-05-08 10:18:37 -07:00
2025-10-29 11:00:23 -07:00
2018-03-01 21:11:16 +00:00
2012-02-24 11:48:19 +11:00
2019-09-08 17:28:20 +00:00
2012-02-24 11:48:19 +11:00
2021-10-06 15:53:04 +00:00

The test directory contains tests of the Go tool chain and runtime. It includes black box tests, regression tests, and error output tests. They are run as part of all.bash.

To run just these tests, execute:

../bin/go test cmd/internal/testdir

To run just tests from specified files in this directory, execute:

../bin/go test cmd/internal/testdir -run='Test/(file1.go|file2.go|...)'

Standard library tests should be written as regular Go tests in the appropriate package.

The tool chain and runtime also have regular Go tests in their packages. The main reasons to add a new test to this directory are:

  • it is most naturally expressed using the test runner; or
  • it is also applicable to gccgo and other Go tool chains.