[llvm] [RegAlloc] Account for use availability when applying rematerializable weight discount (PR #159180)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 19 10:55:20 PDT 2025


================
@@ -1820,3 +1821,54 @@ void LiveIntervals::constructMainRangeFromSubranges(LiveInterval &LI) {
   LICalc->reset(MF, getSlotIndexes(), DomTree, &getVNInfoAllocator());
   LICalc->constructMainRangeFromSubranges(LI);
 }
+
+bool LiveIntervals::allUsesAvailableAt(const MachineInstr &MI,
+                                       SlotIndex UseIdx) const {
+  SlotIndex OrigIdx = getInstructionIndex(MI).getRegSlot(true);
+  UseIdx = std::max(UseIdx, UseIdx.getRegSlot(true));
+  for (const MachineOperand &MO : MI.operands()) {
+    if (!MO.isReg() || !MO.getReg() || !MO.readsReg())
+      continue;
+
+    // We can't remat physreg uses, unless it is a constant or target wants
----------------
preames wrote:

This code is still remat specific, and the placement on LiveIntervals makes that subtly non-obvious.  

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


More information about the llvm-commits mailing list