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

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 21 10:57:35 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:

Emm, `FoldConstantArithmetic` would try folding non-arithmetic node `vector_compress <1, 2>, <3, 4>, <5, 6> ` to a scalar version  `<(vector_compress 1, 3, 5), (vector_compress 2, 4, 6)>`. That's illegal.

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


More information about the llvm-commits mailing list