Skip to content

Commit 82606c4

Browse files
committed
[AMDGPU] Fix lack of LDS DMA check in the AA handling
SIInstrInfo::areMemAccessesTriviallyDisjoint does a DS offset checks, but does not account for LDS DMA instructions. Added these checks. Without it code falls through and returns true which is wrong. As a result mayAlias would always return false for LDS DMA and a regular LDS instruction or 2 LDS DMA instructions. At the moment this is NFCI because we do not use this AA in a context which may touch LDS DMA instructions. This is also unreacheable now because of the ordered memory ref checks just above in the function and LDS DMA is marked as volatile. This volatile marking is removed in PR llvm#75247, therefore I'd submit this check before llvm#75247.
1 parent 7f54070 commit 82606c4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3656,8 +3656,8 @@ bool SIInstrInfo::areMemAccessesTriviallyDisjoint(const MachineInstr &MIa,
36563656
// underlying address space, even if it was lowered to a different one,
36573657
// e.g. private accesses lowered to use MUBUF instructions on a scratch
36583658
// buffer.
3659-
if (isDS(MIa)) {
3660-
if (isDS(MIb))
3659+
if (isDS(MIa) || isLDSDMA(MIa)) {
3660+
if (isDS(MIb) || isLDSDMA(MIb))
36613661
return checkInstOffsetsDoNotOverlap(MIa, MIb);
36623662

36633663
return !isFLAT(MIb) || isSegmentSpecificFLAT(MIb);

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,14 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
546546
return get(Opcode).TSFlags & SIInstrFlags::DS;
547547
}
548548

549+
static bool isLDSDMA(const MachineInstr &MI) {
550+
return isVALU(MI) && (isMUBUF(MI) || isFLAT(MI));
551+
}
552+
553+
bool isLDSDMA(uint16_t Opcode) {
554+
return isVALU(Opcode) && (isMUBUF(Opcode) || isFLAT(Opcode));
555+
}
556+
549557
static bool isGWS(const MachineInstr &MI) {
550558
return MI.getDesc().TSFlags & SIInstrFlags::GWS;
551559
}

0 commit comments

Comments
 (0)