[llvm] [X86][SelectionDAG] - Add support for llvm.canonicalize intrinsic (PR #106370)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 07:56:17 PDT 2024


================
@@ -1275,6 +1275,56 @@ void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
       }
     }
     break;
+    case ISD::FCANONICALIZE: {
+      const Triple &TT = DAG.getTarget().getTargetTriple();
+      if (TT.getArch() == Triple::x86 || TT.getArch() == Triple::x86_64) {
+        SDValue Operand = Node->getOperand(0);
+        SDLoc dl(Node);
+        EVT VT = Operand.getValueType();
+
----------------
arsenm wrote:

Constant folding should be handled in another patch, if it's even necessary. This ideally would be factored into a separate function operating on the APFloat like other constant foldings.

This also does not belong in the legalization, it's a constant folding combine 

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


More information about the llvm-commits mailing list