[llvm] [SDAG][NVPTX] Cache control metadata support and lowering (PR #204067)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 12:49:12 PDT 2026


================
@@ -1332,8 +1333,15 @@ SelectionDAG::AddModifiedNodeToCSEMaps(SDNode *N) {
       // to replace the dead one with the existing one.  This can cause
       // recursive merging of other unrelated nodes down the line.
       Existing->intersectFlagsWith(N->getFlags());
-      if (auto *MemNode = dyn_cast<MemSDNode>(Existing))
-        MemNode->refineRanges(cast<MemSDNode>(N)->memoperands());
+      if (auto *MemNode = dyn_cast<MemSDNode>(Existing)) {
+        ArrayRef<MachineMemOperand *> NewMMOs =
+            cast<MemSDNode>(N)->memoperands();
+        // Range and cache hint metadata are not part of the DAG CSE key because
+        // we prefer to CSE even when metadata does not match. Merge potentially
+        // differing metadata conservatively.
+        MemNode->refineRanges(NewMMOs);
+        MemNode->refineMemCacheHints(NewMMOs);
----------------
arsenm wrote:

Should these 2 be merged into one function to merge all the fields of the MMO? I can't imagine a scenario where you would only want to select a subset of the properties to merge

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


More information about the llvm-commits mailing list