[llvm] [SDAG] Allow folding stack slots into sincos/frexp in more cases (PR #118117)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 08:38:23 PST 2024


================
@@ -2474,6 +2474,45 @@ SDValue SelectionDAG::getPartialReduceAdd(SDLoc DL, EVT ReducedTy, SDValue Op1,
   return Subvectors[0];
 }
 
+/// Given a store node \p StoreNode, return true if it is safe to fold that node
+/// into \p FPNode, which expands to a library call with output pointers.
+static bool CanFoldStoreIntoFPLibCall(StoreSDNode *StoreNode, SDNode *FPNode) {
+  SmallVector<const SDNode *, 8> Worklist;
+  SmallVector<const SDNode *, 8> DeferredNodes;
+  SmallPtrSet<const SDNode *, 16> Visited;
+
+  // Skip FPNode use by StoreNode (that's the use we want to fold into FPNode).
+  for (SDValue Op : StoreNode->ops())
+    if (Op.getNode() != FPNode)
+      Worklist.push_back(Op.getNode());
+
+  while (!Worklist.empty()) {
----------------
arsenm wrote:

There probably should be a more general helper for this, but this needs a depth guard like other searches? 

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


More information about the llvm-commits mailing list