[llvm] 465f2b0 - DAG: Fix asserting in error case for frexp softening (#147236)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 7 02:37:40 PDT 2025
Author: Matt Arsenault
Date: 2025-07-07T18:37:37+09:00
New Revision: 465f2b05712d18b32d5375c096f2406c6dcd700d
URL: https://github.com/llvm/llvm-project/commit/465f2b05712d18b32d5375c096f2406c6dcd700d
DIFF: https://github.com/llvm/llvm-project/commit/465f2b05712d18b32d5375c096f2406c6dcd700d.diff
LOG: DAG: Fix asserting in error case for frexp softening (#147236)
Added:
llvm/test/CodeGen/ARM/frexp-soften-libcall-error.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index d96e9a367aab7..6a4f983077213 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -761,20 +761,21 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FFREXP(SDNode *N) {
EVT VT0 = N->getValueType(0);
EVT VT1 = N->getValueType(1);
RTLIB::Libcall LC = RTLIB::getFREXP(VT0);
+ EVT NVT0 = TLI.getTypeToTransformTo(*DAG.getContext(), VT0);
+ SDLoc DL(N);
if (DAG.getLibInfo().getIntSize() != VT1.getSizeInBits()) {
// If the exponent does not match with sizeof(int) a libcall would use the
// wrong type for the argument.
// TODO: Should be able to handle mismatches.
DAG.getContext()->emitError("ffrexp exponent does not match sizeof(int)");
- return DAG.getUNDEF(N->getValueType(0));
+ SDValue PoisonExp = DAG.getPOISON(VT1);
+ ReplaceValueWith(SDValue(N, 1), PoisonExp);
+ return DAG.getMergeValues({DAG.getPOISON(NVT0), PoisonExp}, DL);
}
- EVT NVT0 = TLI.getTypeToTransformTo(*DAG.getContext(), VT0);
SDValue StackSlot = DAG.CreateStackTemporary(VT1);
- SDLoc DL(N);
-
auto PointerTy = PointerType::getUnqual(*DAG.getContext());
TargetLowering::MakeLibCallOptions CallOptions;
SDValue Ops[2] = {GetSoftenedFloat(N->getOperand(0)), StackSlot};
diff --git a/llvm/test/CodeGen/ARM/frexp-soften-libcall-error.ll b/llvm/test/CodeGen/ARM/frexp-soften-libcall-error.ll
new file mode 100644
index 0000000000000..7a02dbd9d0d11
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/frexp-soften-libcall-error.ll
@@ -0,0 +1,8 @@
+; RUN: not llc -mtriple arm-linux-gnu -float-abi=soft -filetype=null %s 2>&1 | FileCheck %s
+
+; FIXME: This should not fail but isn't implemented
+; CHECK: error: ffrexp exponent does not match sizeof(int)
+define { float, i64 } @soften_frexp_error(float %x) {
+ %frexp = call { float, i64 } @llvm.frexp.f32.i64(float %x)
+ ret { float, i64 } %frexp
+}
More information about the llvm-commits
mailing list