[PATCH] D121366: Allow ImproveChain to get past relaxed atomics

Yoni Lavi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 04:26:40 PDT 2022


yoni-lavi updated this revision to Diff 417565.
yoni-lavi added a comment.

restored content, without debug prints


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121366/new/

https://reviews.llvm.org/D121366

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp


Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -24062,6 +24062,14 @@
               Optional<int64_t>(Size),
               LSN->getMemOperand()};
     }
+    if (const auto *AN = dyn_cast<AtomicSDNode>(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<int64_t>(Size), AN->getMemOperand()};
+    }
     if (const auto *LN = cast<LifetimeSDNode>(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<AtomicSDNode>(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;
     }
   };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121366.417565.patch
Type: text/x-patch
Size: 1389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220323/070ca364/attachment.bin>


More information about the llvm-commits mailing list