Skip to content

Commit d289af4

Browse files
committed
AMDGPU: Expand remaining system atomic operations
System scope atomics need to use cmpxchg loops. aea5980 started this, this expands the set to cover the remaining integer operations. Don't expand xchg and add, those theoretically should work over PCIe.
1 parent 617602d commit d289af4

File tree

9 files changed

+12889
-2062
lines changed

9 files changed

+12889
-2062
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15796,7 +15796,8 @@ SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
1579615796
SSID == SyncScope::System ||
1579715797
SSID == RMW->getContext().getOrInsertSyncScopeID("one-as");
1579815798

15799-
switch (RMW->getOperation()) {
15799+
auto Op = RMW->getOperation();
15800+
switch (Op) {
1580015801
case AtomicRMWInst::FAdd: {
1580115802
Type *Ty = RMW->getType();
1580215803

@@ -15871,18 +15872,28 @@ SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
1587115872

1587215873
return AtomicExpansionKind::CmpXChg;
1587315874
}
15874-
case AtomicRMWInst::FMin:
15875-
case AtomicRMWInst::FMax:
15876-
case AtomicRMWInst::Min:
15875+
case AtomicRMWInst::Xchg:
15876+
case AtomicRMWInst::Add:
15877+
// PCIe supports add and xchg for system atomics.
15878+
break;
15879+
case AtomicRMWInst::Sub:
15880+
case AtomicRMWInst::And:
15881+
case AtomicRMWInst::Or:
15882+
case AtomicRMWInst::Xor:
1587715883
case AtomicRMWInst::Max:
15884+
case AtomicRMWInst::Min:
15885+
case AtomicRMWInst::UMax:
1587815886
case AtomicRMWInst::UMin:
15879-
case AtomicRMWInst::UMax: {
15887+
case AtomicRMWInst::FMin:
15888+
case AtomicRMWInst::FMax:
15889+
case AtomicRMWInst::UIncWrap:
15890+
case AtomicRMWInst::UDecWrap: {
1588015891
if (AMDGPU::isFlatGlobalAddrSpace(AS)) {
15881-
if (RMW->getType()->isFloatTy() &&
15892+
if (AtomicRMWInst::isFPOperation(Op) &&
1588215893
unsafeFPAtomicsDisabled(RMW->getFunction()))
1588315894
return AtomicExpansionKind::CmpXChg;
1588415895

15885-
// Always expand system scope min/max atomics.
15896+
// Always expand system scope atomics.
1588615897
if (HasSystemScope)
1588715898
return AtomicExpansionKind::CmpXChg;
1588815899
}

0 commit comments

Comments
 (0)