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

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 04:15:13 PDT 2025


================
@@ -6740,6 +6740,18 @@ static std::optional<APInt> FoldValue(unsigned Opcode, const APInt &C1,
   }
   return std::nullopt;
 }
+
+static std::optional<APInt> FoldValue(unsigned Opcode, const APInt &C1,
+                                      const APInt &C2, const APInt &C3) {
+  //switch (Opcode) {
+  //case ISD::FSHL:
+    //return APIntOps::fshl(C1, C2, C3);
+  //case ISD::FSHR:
+    //return APIntOps::fshr(C1, C2, C3);
+  //}
+  return std::nullopt;
----------------
XChy wrote:

Sure, I extract the function only for consistency with the binary case:
https://github.com/llvm/llvm-project/blob/dc23869f98452ca2c4086f12bb431a8d6fdb8169/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp#L7111-L7130
If we only handle fshl and fshr cases currently, the function is unnecessary.

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


More information about the llvm-commits mailing list