[llvm] [AMDGPU] Use alias analysis for SMEM/VMEM WAR waitcnts (PR #206569)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 30 02:28:12 PDT 2026
================
@@ -2418,18 +2419,37 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(
// instruction to guarantee the right WAW order.
// 2) If a destination operand that was used by a recent export/store ins,
// add s_waitcnt on exp_cnt to guarantee the WAR order.
-
+ bool CheckedPendingSMRDLoads = false;
for (const MachineMemOperand *Memop : MI.memoperands()) {
const Value *Ptr = Memop->getValue();
- if (Memop->isStore()) {
- if (auto It = SLoadAddresses.find(Ptr); It != SLoadAddresses.end()) {
+ unsigned AS = Memop->getAddrSpace();
+
+ bool IsLDSDMARelevantAS =
+ AS == AMDGPUAS::FLAT_ADDRESS || AS == AMDGPUAS::LOCAL_ADDRESS;
+ // TODO: Rely on SIInstrInfo::areMemAccessesTriviallyDisjoint for this
+ // once it uses MMO address spaces to distinguish lowered memory forms.
+ bool IsSMRDWARRelevantAS = AS == AMDGPUAS::FLAT_ADDRESS ||
+ AMDGPU::isExtendedGlobalAddrSpace(AS);
+
+ if (Memop->isStore() && IsSMRDWARRelevantAS &&
+ !CheckedPendingSMRDLoads) {
+ CheckedPendingSMRDLoads = true;
+
+ SmallVector<MachineInstr *, 4> SMRDLoadsToRemove;
----------------
jayfoad wrote:
Instead of this you could turn the loop below into `PendingSMRDLoads.remove_if(...)`. But I'm not sure if that would be more or less readable overall.
https://github.com/llvm/llvm-project/pull/206569
More information about the llvm-commits
mailing list