[llvm] [AMDGPU][Scheduler] Scoring system for rematerialization candidates (PR #153092)

Lucas Ramirez via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 08:10:50 PDT 2025


================
@@ -2040,6 +2257,13 @@ void GCNScheduleDAGMILive::updateRegionBoundaries(
     RegionBounds.first = NewMI; // Insertion
 }
 
+void GCNScheduleDAGMILive::deleteMI(unsigned RegionIdx, MachineInstr *MI) {
+  updateRegionBoundaries(Regions[RegionIdx], MI, nullptr);
----------------
lucas-rami wrote:

I ended up deleting `updateRegionBoundaries` because I was the only user and it was a somewhat long function that can be replaced with a couple simple lines at both use points. However I don't think I changed the implementation by doing that, and I am not seeing an issue when deleting the only instruction from the region in `deleteMI`.

If `MI` is the only instruction in the region we have `Region.second == std::next(MachineBasicBlock::iterator(MI))` so after the function we will have `Region.first == Region.second`. `test_rollback_remats_emptydefregion` in `machine-scheduler-sink-trivial-remats.mir` tests that we can completely empty a region (bb.1) and then rollback instructions to it again and it seems to work without issue.

https://github.com/llvm/llvm-project/pull/153092


More information about the llvm-commits mailing list