Skip to content

Commit 611212f

Browse files
authored
AMDGPU/GlobalISel: Legalize atomicrmw fmin/fmax (#97048)
We only handled the easy LDS case before. Handle the other address spaces with the more complicated legality logic.
1 parent 6aed0d5 commit 611212f

File tree

3 files changed

+5944
-2
lines changed

3 files changed

+5944
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,10 +1670,22 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
16701670
if (ST.hasAtomicFlatPkAdd16Insts())
16711671
Atomic.legalFor({{V2F16, FlatPtr}, {V2BF16, FlatPtr}});
16721672

1673-
// FIXME: Handle flat, global and buffer cases.
1674-
getActionDefinitionsBuilder({G_ATOMICRMW_FMIN, G_ATOMICRMW_FMAX})
1673+
1674+
// Most of the legalization work here is done by AtomicExpand. We could
1675+
// probably use a simpler legality rule that just assumes anything is OK.
1676+
auto &AtomicFMinFMax =
1677+
getActionDefinitionsBuilder({G_ATOMICRMW_FMIN, G_ATOMICRMW_FMAX})
16751678
.legalFor({{F32, LocalPtr}, {F64, LocalPtr}});
16761679

1680+
if (ST.hasAtomicFMinFMaxF32GlobalInsts())
1681+
AtomicFMinFMax.legalFor({{F32, GlobalPtr},{F32, BufferFatPtr}});
1682+
if (ST.hasAtomicFMinFMaxF64GlobalInsts())
1683+
AtomicFMinFMax.legalFor({{F64, GlobalPtr}, {F64, BufferFatPtr}});
1684+
if (ST.hasAtomicFMinFMaxF32FlatInsts())
1685+
AtomicFMinFMax.legalFor({F32, FlatPtr});
1686+
if (ST.hasAtomicFMinFMaxF64FlatInsts())
1687+
AtomicFMinFMax.legalFor({F64, FlatPtr});
1688+
16771689
// BUFFER/FLAT_ATOMIC_CMP_SWAP on GCN GPUs needs input marshalling, and output
16781690
// demarshalling
16791691
getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG)

0 commit comments

Comments
 (0)