Skip to content

cmd/compile: avoid revisiting shared OR expressions - #82672

Open
JakeNesler wants to merge 1 commit into
golang:masterfrom
JakeNesler:fix-memcombine-20261028
Open

JakeNesler wants to merge 1 commit into
golang:masterfrom
JakeNesler:fix-memcombine-20261028

Conversation

@JakeNesler

@JakeNesler JakeNesler commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Treat shared OR values as separate roots in memcombineLoads and descend
only into single-use arguments. combineLoads cannot combine through
shared internal values, so revisiting them adds work without finding
more load combinations.

A 22-level input with 67 OR values compiled in about 13 ms instead of
1.867 s, with identical assembly. Real application builds showed no
statistically clear speedup or regression.

Fixes #82671

Treat shared OR values as separate roots in memcombineLoads and descend
only into single-use arguments. combineLoads already refuses to combine
through shared internal values, so expanding them cannot help find a
load combination.

Add a benchmark for repeated diamond-shaped expressions and
code-generation checks for a combined load shared by two OR expressions.

In six alternating comparison pairs at 9929116 on 27 October, a
22-level input with 67 OR values compiled in about 13 ms instead of
1.867 s, with identical assembly. Real application builds showed no
statistically clear speedup or regression.

Tests passed on linux/arm64 at 63313a0 with the candidate source
overlay and, for code-generation checks, the rebuilt compiler:

go test -count=3 -overlay=/work/memcombine-arm64.json cmd/compile/internal/ssa cmd/compile/internal/ssacompile
go test -count=1 cmd/internal/testdir '-run=^Test/codegen/memcombine.go$' -args -all_codegen
go test -count=1 cmd/internal/testdir '-run=^Test/prove.go$'

The package tests also passed on linux/amd64. Full all.bash was not run.

CartoGopher tooling for source navigation; reproduction, implementation
and testing with Codex.

Fixes golang#82671
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 6dae9ba) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/855621.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Jacob Nesler (Jake Nesler):

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from David Chase:

Patch Set 3: Code-Review+2 Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-10-30T01:19:46Z","revision":"a41389368b1b31afb1cd39b9a293a74343a63c02"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Cuong Manh Le:

Patch Set 3: Code-Review+2


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from David Chase:

Patch Set 3: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_7061>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/855621.
After addressing review feedback, remember to publish your drafts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmd/compile: exponential traversal of shared OR expressions

2 participants