================
@@ -601,11 +601,79 @@ void
AMDGPURewriteAGPRCopyMFMAImpl::eliminateSpillsOfReassignedVGPRs() const {
return false;
};
- if (!llvm::all_of(Loads, IsLoadJointlyDominatedByStores)) {
- LLVM_DEBUG(
- dbgs() << "Skipping " << printReg(Slot, &TRI)
- << ": some reachable load not jointly dominated by stores\n");
- continue;
+ // Collect basic blocks of any loads not jointly dominated by stores. After
+ // rewriting, we will attempt to insert a single IMPLICIT_DEF for those
uses
+ // of NewVReg.
+ SmallVector<MachineBasicBlock *, 4> ProblematicLoadMBBs;
+ for (MachineInstr *L : Loads) {
+ if (!IsLoadJointlyDominatedByStores(L))
+ ProblematicLoadMBBs.push_back(L->getParent());
+ }
+
+ // If we have problematic reloads, compute the IMPLICIT_DEF insertion
+ // block. Safety condition for the insertion block P:
+ // (a) P dominates every problematic load, and
+ // (b) On every entry->P path no spill store has executed yet (so the
+ // IMPLICIT_DEF cannot clobber a real spill-store COPY-def on
+ // any path that reaches it).
+ //
+ // Build MayStored, where MayStored[B] is true iff some entry->B path
+ // crossed a store block strictly before B. (b) is equivalent to
+ // "P is not in MayStored".
+ MachineBasicBlock *ImplicitDefMBB = nullptr;
+ if (!ProblematicLoadMBBs.empty()) {
+ SmallPtrSet<MachineBasicBlock *, 16> MayStored;
----------------
arsenm wrote:
There's already a worklist above, can you just do one CFG analysis
https://github.com/llvm/llvm-project/pull/200126
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits