[llvm] [DAG] Constant fold ISD::FSHL/FSHR nodes (PR #154480)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 10:20:24 PDT 2025


================
@@ -8158,6 +8180,12 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
     }
     break;
   }
+  case ISD::FSHL:
+  case ISD::FSHR:
+    // Constant folding.
+    if (SDValue V = FoldConstantArithmetic(Opcode, DL, VT, {N1, N2, N3}))
+      return V;
+    break;
----------------
XChy wrote:

IIUC, it doesn't work for constant vectors without the modification in `getNode`. The constant fold for vector depends on constant fold in `getNode`:
https://github.com/llvm/llvm-project/blob/bce9b6d1771bbcf6d250935fdaab1dfa0922fd72/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L7330


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


More information about the llvm-commits mailing list