-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rematerialization #8
Comments
I'm currently looking to implement the simple rematerialization scheme I described above. Here's a summary of the changes I think are needed:
@cfallin Does this seem reasonable to you? |
@Amanieu: yes, overall, this looks quite reasonable! Thank you very much for working on this. A few thoughts:
I agree re: above that "complex remat" (repeating insts with other vreg inputs) is a much deeper project and probably not necessary for a large chunk of the benefit (namely, constant values and maybe global/argument/other environment-context loads). It might be worth looking into what other compilers do here at some point, out of curiosity if nothing else -- I don't know much about the state of the art in remat. Anyway, happy to talk more as you look at this! |
The problem is that any other vreg we merge with will almost certainly not be rematerializable on its own, usually because it has multiple possible values (e.g. a block parameter, but this also applies to moves). The rematerialization only applies to one of these values but at that point we don't know which value that vreg will take. |
As an alternative to spilling and reloading, a vreg value can sometimes be recomputed from other available values. There are two ways this can be supported in regalloc2:
Simple rematerialization
Supporting rematerialization for constants, including runtime constants which only depend on pinned registers (e.g. VMContext), is relatively straightforward. The client needs to track rematerialization metadata for each
VReg
, after which we can elide spills for this vreg (unless there is a stack use) and replace reloads with rematerializations.Complex rematerialization
Rematerialization involving values in other vregs is more complex and probably not worth the effort of implementing. It has been done before as part of a research project on V8 but AFAIK this has not made it into the main V8 codebase.
The text was updated successfully, but these errors were encountered: