[llvm] [SelectionDAG] Emit error instead of asserting for unsupported FP_EXTEND (PR #182660)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 21 09:18:14 PST 2026


https://github.com/bala-bhargav updated https://github.com/llvm/llvm-project/pull/182660

>From a5da7ded8396a915451c9396a899d80e80bd2b7a Mon Sep 17 00:00:00 2001
From: bhargav <penugondabalabharghav at gmail.com>
Date: Sat, 21 Feb 2026 14:36:27 +0530
Subject: [PATCH] [SelectionDAG] Emit error instead of asserting for
 unsupported FP_EXTEND (#182449)

---
 llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp |  7 ++++++-
 .../CodeGen/AArch64/unsupported-fpext-x86-fp80.ll    | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll

diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 16453f220bb50..bc04a198bb85b 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -655,7 +655,12 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FP_EXTEND(SDNode *N) {
   }
 
   RTLIB::Libcall LC = RTLIB::getFPEXT(Op.getValueType(), N->getValueType(0));
-  assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_EXTEND!");
+  if (LC == RTLIB::UNKNOWN_LIBCALL) {
+    DAG.getContext()->emitError("do not know how to soften fp_extend");
+    if (IsStrict)
+      ReplaceValueWith(SDValue(N, 1), Chain);
+    return DAG.getPOISON(NVT);
+  }
   TargetLowering::MakeLibCallOptions CallOptions;
   EVT OpVT = N->getOperand(IsStrict ? 1 : 0).getValueType();
   CallOptions.setTypeListBeforeSoften(OpVT, N->getValueType(0));
diff --git a/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll b/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll
new file mode 100644
index 0000000000000..83e397825dfc7
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/unsupported-fpext-x86-fp80.ll
@@ -0,0 +1,12 @@
+; RUN: not llc -mtriple=aarch64-unknown-linux-gnu < %s 2>&1 | FileCheck %s
+
+; Verify that we get a user-friendly error instead of an assertion failure
+; when trying to fpext to x86_fp80 on AArch64 (which has no libcall for it).
+; See: https://github.com/llvm/llvm-project/issues/182449
+
+; CHECK: error: do not know how to soften fp_extend
+
+define x86_fp80 @test_fpext_double_to_x86_fp80(double %x) {
+  %ext = fpext double %x to x86_fp80
+  ret x86_fp80 %ext
+}



More information about the llvm-commits mailing list