[llvm] [AMDGPU] Allow rematerialization of instructions with virtual register uses (PR #124327)
Jeffrey Byrnes via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 13:26:53 PST 2025
================
@@ -1615,6 +1615,59 @@ void GCNSchedStage::revertScheduling() {
DAG.Regions[RegionIdx] = std::pair(DAG.RegionBegin, DAG.RegionEnd);
}
+/// allUsesAvailableAt - Return true if all registers used by InstToRemat at
+/// OriginalIdx are also available with the same value at RematIdx.
+bool PreRARematStage::allUsesAvailableAt(const MachineInstr *InstToRemat,
+ SlotIndex OriginalIdx,
+ SlotIndex RematIdx) const {
+
+ LiveIntervals *LIS = DAG.LIS;
+ MachineRegisterInfo &MRI = DAG.MRI;
+ OriginalIdx = OriginalIdx.getRegSlot(true);
+ RematIdx = std::max(RematIdx, RematIdx.getRegSlot(true));
+ for (const MachineOperand &MO : InstToRemat->operands()) {
+ if (!MO.isReg() || !MO.getReg() || !MO.readsReg())
+ continue;
+
+ if (!MO.getReg().isVirtual())
----------------
jrbyrnes wrote:
Hey Stas -- thanks for catch; you're right, this needs to be handled, we currently don't check liveness either: https://godbolt.org/z/xjPjdcorf
https://github.com/llvm/llvm-project/pull/124327
More information about the llvm-commits
mailing list