Enable the PreRARematerialize pass when there are multiple high RP scheduling
regions present. Require the occupancy in all high RP regions be improved
before finalizing sinking. If any high RP region did not improve in occupancy
then un-do all sinking and restore the state to before the pass.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp | ||
---|---|---|
657–658 | Fix the formatting as tidy suggests. | |
731 | Unrelated to this patch. Can you separately change this to hasOneNonDBGUse()? | |
739 | This also needs a nodbg use (use_nodbg_instructions). | |
753 | It has one use, so you can break from the loop here. | |
783 | This is expensive to make a full copy of everything, even though you only need a small number of regions. | |
794–805 | It is better to have an inverted logic, initialize it to false and only set to true if actually improved anything. | |
863 | Has this *Reg* as a live-in. | |
881 | Don't you need to remove Reg from NewLiveIns at this point for all regions? | |
910 | It is probably also possible to call updateRegionBoundaries to restore the state. | |
911 | return false; | |
940–941 | Actually ++MinOccupancy suggests 1 step improvement. It can be higher, but you do not really know as you would need to check all other blocks too. | |
942 | return true; |
Fix formatting and comments.
Reduce required copies of cached Pressure and Liveins.
Update Pressure and Liveins for all regions where the reg is live-in when sinking.
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp | ||
---|---|---|
739 | If there is a debug use before the first nondbg use, this will sink the MI after the debug use. | |
753 | We also want to collect the def if it is live-through. If we only collect uses, we may skip a trivially rematerializable def that is used in a low RP region but is increasing RP for a high RP region due to being live-through. | |
881 | Updated to also remove Reg from all regions' LiveIns set and re-calculate RP for regions where the Reg was live-in including regions not at MinOccupancy. This should keep cached Pressure and LiveIns up to date after sinking. | |
910 | I am not sure if we can call updateRegionBoundaries. If we sink two defs and both regions are now empty, it will not be possible to tell which def belonged to which region because both will point to the end of block iterator. |
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp | ||
---|---|---|
881 | Actually we also need to update the region where the def was sunk from so cached Pressure is not up to date. Added a FIXME. |
Fix the formatting as tidy suggests.