Skip to content

[pull] master from golang:master#139

Merged
kevin-valerio merged 8 commits into
trailofbits:masterfrom
golang:master
Jul 18, 2026
Merged

[pull] master from golang:master#139
kevin-valerio merged 8 commits into
trailofbits:masterfrom
golang:master

Conversation

@pull

@pull pull Bot commented Jul 18, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

MITSUNARI Shigeo and others added 6 commits July 17, 2026 11:47
…onstant

For unsigned 32-bit division by a constant d on 64-bit targets (amd64,
arm64, riscv64, ...), when the magic multiplier M = 2^32 + m has m odd
(i.e. M is truly 33-bit and cannot be halved to fit in 32 bits), use a
pre-shifted constant C = M << (32 - s) so that a single Hmul64u gives
the quotient directly:

      x / d = Hmul64u(ZeroExt32to64(x), C)

This replaces the avg-based sequence for odd divisors (Case 3) and the
SHR+IMULQ+SHR sequence for even divisors whose underlying magic is
33-bit (e.g. d=14=2×7). Divisors where m is even (Case 6) keep their
existing 32-bit constant path to avoid loading a large 64-bit constant
on arm64/riscv64.

Benchmark on Intel Xeon w9-3495X (3 divisions per iteration, go1.26.3):
  BenchmarkOdd  (d=7,19,107):   3.07 ns/op → 1.92 ns/op  (~38% faster)
  BenchmarkEven (d=14,38,214):  2.04 ns/op → 1.92 ns/op  (~6% faster)

Ref: https://arxiv.org/abs/2604.07902
     llvm/llvm-project#181288

Fixes #79780

Change-Id: I33f551f4f6715ddbcc39f9f56c1331f31f0eca33
Reviewed-on: https://go-review.googlesource.com/c/go/+/785960
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Added a newline after each section header and its following paragraph,
so the sections would render properly.

Ran gofmt, which indented the code blocks with tab characters and
replaced * bullets with - ones.

Note: this documentation is intentionally NOT general package
documentation, but is now formatted consistently with other doc
comments.

For #80397

Change-Id: Ib651e204fc9813122934357a67f3c75bd453483c
Reviewed-on: https://go-review.googlesource.com/c/go/+/801900
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
t.Parallel and the operations that forbid it (t.Setenv, t.Chdir, and
cryptotest.SetGlobalRandom) shared a single panic message that listed all
three operations, so the panic never named the one that actually caused the
conflict. A test that only calls t.Setenv could panic with a message
mentioning cryptotest.SetGlobalRandom, which is confusing.

Record the specific operation that denies parallelism and report it in both
directions: when t.Parallel is called after one of those operations, and
when one of them is called on a test that is already parallel.

Fixes #80267

Change-Id: I749e22f3e6df3552795c512636a5d2466d95af4f
GitHub-Last-Rev: 68ecf1b
GitHub-Pull-Request: #80313
Reviewed-on: https://go-review.googlesource.com/c/go/+/798641
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Sean Liao <sean@liao.dev>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Fixes #77320

Change-Id: I1ca7480dceb0a95d223ae1618c0e9dd23abe5d49
Reviewed-on: https://go-review.googlesource.com/c/go/+/787940
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
We don't support binary-only packages, and haven't for a while. We would
only check for binary only packages when actually executing the action
graph. But it seems more natural to report the error when loading
packages. The only difference is the reporting of staleness but it
doesn't really make sense to report staleness if we don't even support
building those packages.

While we're here remove the unused needStale need bit.

This also slightly simplifies the logic in checkCacheForBuild.

For #28152

Change-Id: I2bad74152d2c4323026c7513537265a36a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/799002
Auto-Submit: Michael Matloob <matloob@golang.org>
TryBot-Bypass: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
Reviewed-by: Hongxiang Jiang <hxjiang@golang.org>
This CL addresses https://go-review.googlesource.com/c/go/+/799984/comments/03458ed5_ce76e7f6

Fixes #80278

Change-Id: Id32c6ef68aad91dcbccf2e6e5e9822656a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/801620
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@google.com>
@pull pull Bot locked and limited conversation to collaborators Jul 18, 2026
@pull pull Bot added ⤵️ pull merge-conflict Resolve conflicts manually labels Jul 18, 2026
@pull
pull Bot requested a review from kevin-valerio July 18, 2026 00:37
josharian and others added 2 commits July 17, 2026 18:47
I filed #49331 about five years ago, suggesting that the compiler
should re-associate some computations to support ILP.

There was general consensus that it was a decent idea,
and I believe that Ryan Berger may have attempted it,
but so far, nothing has landed.

For md5 in particular, which was the motivating example,
we can get the desired parallelism by adjusting the source code.
So do that. We can always revert if/when the compiler pass lands.

Each MD5 step is of the form

arg0 = arg1 + RotateLeft32(F(arg1,arg2,arg3) + arg0 + x + k, s)

where arg1 is the output of the previous step.

The generated code has the form a+(b+(c+d)) rather than (a+b)+(c+d),
which has a long serial dependency chain.

This is a significant source of the performance difference between
the generic Go code and the handwritten assembly.

Adjust the generator to impose the association we desire.
Group the arg1-independent terms as F + (arg0+x+k).
This lets the compiler schedule the inner sum in parallel with F,
trimming the chain to a single add after F is calculated.

Add two further expression tweaks.

In round 2, use the direct selection form (x&z)|(y&^z)
instead of the XOR-trick form ((x^y)&z)^y.
The direct form puts arg1 on a 2-op path to F instead of 3,
which reduces serialization on the critical path and shortens variable lifetimes.
On arm64, both forms are 3 logical ops.
On default amd64, this adds an instruction,
but it's off the critical path.
And BMI1 is available at GOAMD64 >= v3.

In round 3, associate arg1^arg2^arg3 as arg1^(arg2^arg3), again for ILP.

Before this commit, asm was about ~30% faster than purego on my arm64
machine, and ~37% on the amd64 machine I have access to (no GOAMD64).

This commit narrows the gap to ~13% and ~20%, respectively.

I have follow-up work planned that shrinks the gap further
and should enable deletion of the md5 assembly.

Updates #49248
Updates #49331

Change-Id: Ia317e20cd73c88c4fb9303b31f5b6b441bfa6b63
Reviewed-on: https://go-review.googlesource.com/c/go/+/801240
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This CL should have been part of CL 796480, but was mistakenly omitted.

Updates #77485.

Change-Id: Ib18dbbcd01ad2080d14c64494e2c71421a1bd2f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/801960
Reviewed-by: Richard Miller <millerresearch@gmail.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
@kevin-valerio
kevin-valerio merged commit 60db14f into trailofbits:master Jul 18, 2026
1 check was pending
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

⤵️ pull merge-conflict Resolve conflicts manually

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants