Skip to content

Commit 465f2b0

Browse files
authored
DAG: Fix asserting in error case for frexp softening (#147236)
1 parent 7cd1796 commit 465f2b0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,20 +761,21 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_FFREXP(SDNode *N) {
761761
EVT VT0 = N->getValueType(0);
762762
EVT VT1 = N->getValueType(1);
763763
RTLIB::Libcall LC = RTLIB::getFREXP(VT0);
764+
EVT NVT0 = TLI.getTypeToTransformTo(*DAG.getContext(), VT0);
765+
SDLoc DL(N);
764766

765767
if (DAG.getLibInfo().getIntSize() != VT1.getSizeInBits()) {
766768
// If the exponent does not match with sizeof(int) a libcall would use the
767769
// wrong type for the argument.
768770
// TODO: Should be able to handle mismatches.
769771
DAG.getContext()->emitError("ffrexp exponent does not match sizeof(int)");
770-
return DAG.getUNDEF(N->getValueType(0));
772+
SDValue PoisonExp = DAG.getPOISON(VT1);
773+
ReplaceValueWith(SDValue(N, 1), PoisonExp);
774+
return DAG.getMergeValues({DAG.getPOISON(NVT0), PoisonExp}, DL);
771775
}
772776

773-
EVT NVT0 = TLI.getTypeToTransformTo(*DAG.getContext(), VT0);
774777
SDValue StackSlot = DAG.CreateStackTemporary(VT1);
775778

776-
SDLoc DL(N);
777-
778779
auto PointerTy = PointerType::getUnqual(*DAG.getContext());
779780
TargetLowering::MakeLibCallOptions CallOptions;
780781
SDValue Ops[2] = {GetSoftenedFloat(N->getOperand(0)), StackSlot};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
; RUN: not llc -mtriple arm-linux-gnu -float-abi=soft -filetype=null %s 2>&1 | FileCheck %s
2+
3+
; FIXME: This should not fail but isn't implemented
4+
; CHECK: error: ffrexp exponent does not match sizeof(int)
5+
define { float, i64 } @soften_frexp_error(float %x) {
6+
%frexp = call { float, i64 } @llvm.frexp.f32.i64(float %x)
7+
ret { float, i64 } %frexp
8+
}

0 commit comments

Comments
 (0)