cmd/compile: don't move/copy rematerializeable op when allocating registers #55039
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
$ cat foo.go
$ go tool compile -S foo.go | less
What did you expect to see?
The instruction
MOVD $<unlinkable>..autotmp_3-512(SP), R2
is out of the loop.What did you see instead?
The instruction
MOVD $<unlinkable>..autotmp_3-512(SP), R2
is in the loop and executed every iteration.Analysis:
This MOVD instruction is assembled from the
MOVDaddr
OP, which is a rematerializeable OP and in block b2, and the op is out of the loop. When it's used in block b10 and allocating a register to it, it's copied from b2 to b10, so it's moved into the loop. I think this is a general problem of allocating registers for rematerializeable OPs, independent of specific architecture, OS and specific OP.One way I can think of is treating rematerializeable OP as usual OP when allocating registers, and when the register is not enough, clobber rematerializeable OP's registers first, and we do not need to load it from memory when unspilling the rematerializeable OP , just redo the OP because it is rematerializeable. This method is similar with that of Graal.
cc @randall77 @cherrymui
The text was updated successfully, but these errors were encountered: