[llvm] [SelectionDAG][RISCV] Avoid store merging across function calls (PR #130430)

Mikhail R. Gadelha via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 17 10:16:36 PDT 2025


================
@@ -21553,6 +21553,56 @@ bool DAGCombiner::tryStoreMergeOfLoads(SmallVectorImpl<MemOpLink> &StoreNodes,
       JointMemOpVT = EVT::getIntegerVT(Context, SizeInBits);
     }
 
+    auto HasCallInLdStChain = [](SmallVectorImpl<MemOpLink> &StoreNodes,
+                                 SmallVectorImpl<MemOpLink> &LoadNodes,
+                                 unsigned NumStores) {
+      for (unsigned i = 0; i < NumStores; ++i) {
+        StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
+        SDValue Val = peekThroughBitcasts(St->getValue());
+        LoadSDNode *Ld = cast<LoadSDNode>(Val);
+        assert(Ld == LoadNodes[i].MemNode && "Load and store mismatch");
+
+        SmallPtrSet<const SDNode *, 32> Visited;
+        SmallVector<std::pair<const SDNode *, bool>, 8> Worklist;
+        Worklist.emplace_back(St->getOperand(0).getNode(), false);
----------------
mikhailramalho wrote:

ohhh, yes, you're right! I thought that was on: 
```
          default:
            assert(Node->getOperand(0).getValueType() == MVT::Other &&
                   "Invalid chain type");
            Worklist.emplace_back(Node->getOperand(0).getNode(), FoundCall);
            break;
          }
```
I'll change it, thanks 

https://github.com/llvm/llvm-project/pull/130430


More information about the llvm-commits mailing list