diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -24062,6 +24062,14 @@ Optional(Size), LSN->getMemOperand()}; } + if (const auto *AN = dyn_cast(N)) { + // PRE_INC / PRE_DEC allegedly not a relevant issue, can set this to zero + int64_t Offset = 0; + uint64_t Size = + MemoryLocation::getSizeOrUnknown(AN->getMemoryVT().getStoreSize()); + return {AN->isVolatile(), AN->isAtomic(), AN->getBasePtr(), + Offset, Optional(Size), AN->getMemOperand()}; + } if (const auto *LN = cast(N)) return {false /*isVolatile*/, /*isAtomic*/ false, LN->getOperand(1), (LN->hasOffset()) ? LN->getOffset() : 0, @@ -24221,6 +24229,15 @@ return false; } default: + if (auto *AC = dyn_cast(C.getNode())) { + if (AC->getMergedOrdering() == AtomicOrdering::Monotonic) { + bool IsOpLoad = AC->getOpcode() == ISD::ATOMIC_LOAD; + if ((IsLoad && IsOpLoad) || !mayAlias(N, AC)) { + C = C.getOperand(0); + return true; + } + } + } return false; } };