diff options
| author | dorbmon <dorbmons@gmail.com> | 2026-02-23 15:20:20 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-10 20:06:05 -0700 |
| commit | 38ac6577cb8cf1ad6cb86cc9a0b6a76276932a79 (patch) | |
| tree | 0f885cc811941adbd05951b8518a117403636774 /src/bytes/bytes_test.go | |
| parent | bcc369284d5ed042e1155ac11ccf15ea2990a64e (diff) | |
| download | go-38ac6577cb8cf1ad6cb86cc9a0b6a76276932a79.tar.xz | |
cmd/compile: forward small Load through Move to avoid redundant copies
Fixes #77720
Add a generic SSA rewrite that forwards `Load` from a `Move` destination
back to the `Move` source when it is provably safe, so field reads like
`s.h.Value().typ` don’t force a full struct copy.
- Add `Load <- Move` rewrite in `generic.rules` with safety guard:
non-volatile source
- Tweak `fixedbugs/issue22200*` so that it can still trigger the "stack frame too large" error.
- Regenerate `rewritegeneric.go`.
- Add `test/codegen/moveload.go` to assert no `MOVUPS` and direct `MOVBLZX`
in both direct and inlined forms.
Benchmark results (linux/amd64, i7-14700KF):
$ go test cmd/compile/internal/test -run='^$' -bench='MoveLoad' -count=20
Before:
BenchmarkMoveLoadTypViaValue-20 ~76.9 ns/op
BenchmarkMoveLoadTypViaPtr-20 ~1.97 ns/op
After:
BenchmarkMoveLoadTypViaValue-20 ~1.894 ns/op
BenchmarkMoveLoadTypViaPtr-20 ~1.905 ns/op
The rewrite removes the redundant struct copy in
`s.h.Value().typ`, bringing it in line with the direct pointer form.
Change-Id: Iddf2263e390030ba013e0642a695b87c75f899da
Reviewed-on: https://go-review.googlesource.com/c/go/+/748200
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>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Diffstat (limited to 'src/bytes/bytes_test.go')
0 files changed, 0 insertions, 0 deletions
