Index: lib/Target/AMDGPU/SIMemoryLegalizer.cpp =================================================================== --- lib/Target/AMDGPU/SIMemoryLegalizer.cpp +++ lib/Target/AMDGPU/SIMemoryLegalizer.cpp @@ -105,14 +105,11 @@ /// "None" otherwise. static Optional getAtomicFenceInfo( const MachineBasicBlock::iterator &MI); - /// \returns Atomic cmpxchg info if \p MI is an atomic cmpxchg operation, + /// \returns Atomic cmpxchg/rmw info if \p MI is an atomic cmpxchg or + /// rmw operation, /// "None" otherwise. static Optional getAtomicCmpxchgInfo( const MachineBasicBlock::iterator &MI); - /// \returns Atomic rmw info if \p MI is an atomic rmw operation, - /// "None" otherwise. - static Optional getAtomicRmwInfo( - const MachineBasicBlock::iterator &MI); /// \brief Reports unknown synchronization scope used in \p MI to LLVM /// context. @@ -190,14 +187,10 @@ /// instructions are added/deleted or \p MI is modified, false otherwise. bool expandAtomicFence(const SIMemOpInfo &MOI, MachineBasicBlock::iterator &MI); - /// \brief Expands atomic cmpxchg operation \p MI. Returns true if + /// \brief Expands atomic cmpxchg or rmw operation \p MI. Returns true if /// instructions are added/deleted or \p MI is modified, false otherwise. bool expandAtomicCmpxchg(const SIMemOpInfo &MOI, MachineBasicBlock::iterator &MI); - /// \brief Expands atomic rmw operation \p MI. Returns true if - /// instructions are added/deleted or \p MI is modified, false otherwise. - bool expandAtomicRmw(const SIMemOpInfo &MOI, - MachineBasicBlock::iterator &MI); public: static char ID; @@ -322,22 +315,6 @@ } /* static */ -Optional SIMemOpInfo::getAtomicRmwInfo( - const MachineBasicBlock::iterator &MI) { - assert(MI->getDesc().TSFlags & SIInstrFlags::maybeAtomic); - - if (!(MI->mayLoad() && MI->mayStore())) - return None; - - // Be conservative if there are no memory operands. - if (MI->getNumMemOperands() == 0) - return SIMemOpInfo(SyncScope::System, - AtomicOrdering::SequentiallyConsistent); - - return SIMemOpInfo::constructFromMIWithMMO(MI); -} - -/* static */ void SIMemOpInfo::reportUnknownSyncScope( const MachineBasicBlock::iterator &MI) { DiagnosticInfoUnsupported Diag(MI->getParent()->getParent()->getFunction(), @@ -546,43 +523,6 @@ return Changed; } -bool SIMemoryLegalizer::expandAtomicRmw(const SIMemOpInfo &MOI, - MachineBasicBlock::iterator &MI) { - assert(MI->mayLoad() && MI->mayStore()); - - bool Changed = false; - - if (MOI.isAtomic()) { - if (MOI.getSSID() == SyncScope::System || - MOI.getSSID() == MMI->getAgentSSID()) { - if (MOI.getOrdering() == AtomicOrdering::Release || - MOI.getOrdering() == AtomicOrdering::AcquireRelease || - MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) - Changed |= insertWaitcntVmcnt0(MI); - - if (MOI.getOrdering() == AtomicOrdering::Acquire || - MOI.getOrdering() == AtomicOrdering::AcquireRelease || - MOI.getOrdering() == AtomicOrdering::SequentiallyConsistent) { - Changed |= insertWaitcntVmcnt0(MI, false); - Changed |= insertBufferWbinvl1Vol(MI, false); - } - - return Changed; - } - - if (MOI.getSSID() == SyncScope::SingleThread || - MOI.getSSID() == MMI->getWorkgroupSSID() || - MOI.getSSID() == MMI->getWavefrontSSID()) { - Changed |= enableGLCBit(MI); - return Changed; - } - - llvm_unreachable("Unsupported synchronization scope"); - } - - return Changed; -} - bool SIMemoryLegalizer::runOnMachineFunction(MachineFunction &MF) { bool Changed = false; const SISubtarget &ST = MF.getSubtarget(); @@ -609,8 +549,6 @@ Changed |= expandAtomicFence(MOI.getValue(), MI); else if (const auto &MOI = SIMemOpInfo::getAtomicCmpxchgInfo(MI)) Changed |= expandAtomicCmpxchg(MOI.getValue(), MI); - else if (const auto &MOI = SIMemOpInfo::getAtomicRmwInfo(MI)) - Changed |= expandAtomicRmw(MOI.getValue(), MI); } }