[llvm] [InlineSpiller] Check rematerialization before folding operand (PR #134015)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 11:25:14 PDT 2025
================
@@ -615,6 +620,23 @@ bool InlineSpiller::canGuaranteeAssignmentAfterRemat(Register VReg,
return true;
}
+/// hasPhysRegAvailable - Check if there is an available physical register for
+/// rematerialization.
+bool InlineSpiller::hasPhysRegAvailable(const MachineInstr &MI) {
+ if (!Order || !Matrix)
+ return false;
+
+ SlotIndex UseIdx = LIS.getInstructionIndex(MI).getRegSlot(true);
+ SlotIndex PrevIdx = UseIdx.getPrevSlot();
+
+ for (MCPhysReg PhysReg : *Order) {
+ if (!Matrix->checkInterference(PrevIdx, UseIdx, PhysReg))
+ return true;
+ }
----------------
weiguozhi wrote:
This function is called only when an MI has following properties:
```
MI->isRematerializable() && MI->canFoldAsLoad() && !MI->mayLoad()
```
I don't expect many instructions satisfy them. I will run a compile time test for it.
https://github.com/llvm/llvm-project/pull/134015
More information about the llvm-commits
mailing list