]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't preload registers if destination already scheduled
authorkhr@golang.org <khr@golang.org>
Wed, 14 May 2025 00:53:45 +0000 (17:53 -0700)
committerKeith Randall <khr@golang.org>
Tue, 20 May 2025 00:13:21 +0000 (17:13 -0700)
commit524946d2475d0b541ba84396f759b9e4c7aa4a98
tree56d702a2edc4eb2d9599d52ea2ae5711a00415b5
parentce88e341b90a0878385535bcb54206ec97bcc518
cmd/compile: don't preload registers if destination already scheduled

In regalloc, we allocate some values to registers before loop entry,
so that they don't need to be loaded (from spill locations) during
the loop.

But it is pointless if we've already regalloc'd the loop body.
Whatever restores we needed for the body are already generated.

It's not clear if this code is ever useful. No tests fail if I just
remove it. But at least this change is worthwhile. It doesn't help,
and it actively inserts more restores than we really need (mostly
because the desired register list is approximate - I have seen cases
where the loads implicated here end up being dead because the restores
hit the wrong registers and the edge shuffle pass knows it needs
the restores in different registers).

While we are here, might as well have layoutRegallocOrder return
the standard layout order instead of recomputing it.

Change-Id: Ia624d5121de59b6123492603695de50b272b277f
Reviewed-on: https://go-review.googlesource.com/c/go/+/672735
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/layout.go
src/cmd/compile/internal/ssa/regalloc.go