-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the register allocator to move live variables.
Previously, if we used a register which contained an existing value, and that value was still live, we spilled it. Spills/unspills are quite expensive, so this was a bit annoying. This PR rewrites the GP register assigning function so that, if there are unused registers available, it will move a value into a register rather than spilling it. Previously this was impossible, because we spilled registers before we'd fully evaluated every constraint. The basic idea is that we assign registers to every constraint before we think about moving/spilling. Once that's done, we then see if the assigned registers require us to move/spill. To my surprise, this rewrite makes the code easier to understand, because there's now a clear split between "satisfy constraints" and "update global state", whereas the two were muddled together before. This currently isn't a huge win in the benchmarks I see -- though it is a small win! -- because the `InputOutput` constraint sometimes obscures the fact that we *could* have had the machine code naturally do the "move" for us. I'll think about how we can avoid that in a future PR.
- Loading branch information
Showing
2 changed files
with
178 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters