[llvm] [SelectionDAG] Do not use illegal type when expanding `CONVERT_FROM_ARBITRARY_FP` (PR #219597)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 05:39:59 PDT 2026


================
@@ -9750,10 +9810,20 @@ TargetLowering::expandCONVERT_FROM_ARBITRARY_FP(SDNode *Node,
 
   // Work in an integer type matching the destination float width.
   EVT IntScalarVT = EVT::getIntegerVT(*DAG.getContext(), DstBits);
-  EVT IntVT = DstVT.isVector()
-                  ? EVT::getVectorVT(*DAG.getContext(), IntScalarVT,
-                                     DstVT.getVectorElementCount())
-                  : IntScalarVT;
+  EVT IntVT = IntScalarVT;
+  if (DstVT.isVector()) {
+    IntVT = EVT::getVectorVT(*DAG.getContext(), IntScalarVT,
+                             DstVT.getVectorElementCount());
+  } else if (!isTypeLegal(IntScalarVT)) {
+    // Avoid generating illegal type as there is no other places that'll
+    // legalize it. Vector types don't have this problem because they
+    // are subject to LegalizeVectorOps and another type legalization phase
+    // will follow.
+    if (getTypeAction(*DAG.getContext(), IntScalarVT) != TypePromoteInteger)
+      // We only know how to handle situations where the legal type is wider.
+      return SDValue();
----------------
arsenm wrote:

This isn't poison?

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


More information about the llvm-commits mailing list