[CodeGen] Introduce MIR-level target-independent rematerialization helper #177080
+1,629
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a
Rematerializerclass that identifies register rematerialization opportunities within a machine function and provides an API to easily perform those rematerializations with a high level of control. Its key feature is its ability to model relationships between rematerializable registers and rematerialize arbitrarily complex groups of registers at once to specific locations. The class comment describes the underlying model in details.This includes unit tests for the class to both verify its correct behavior and showcase its current rematerialization capabilities.
This hopefully can be a step toward addressing long-standing rematerialization limitations in LLVM backends. In the future, the goal is to pair this support with generic or target-dependent strategies for picking the best rematerialization opportunities to perform to achieve some kind of objective (e.g., a specific register pressure target in scheduling regions). As a concrete example, I intend to use this in the AMDGPU scheduler to help in reducing spilling and/or increasing occupancy in kernels.