diff options
author | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-07-08 14:22:45 +0000 |
---|---|---|
committer | Bill Schmidt <wschmidt@linux.vnet.ibm.com> | 2013-07-08 14:22:45 +0000 |
commit | 2db29ef4677b20b250cd75ab889281aed2f12705 (patch) | |
tree | 26725220604fcfc5217215a7935d051cbab08fbe /llvm/lib/Target/PowerPC/PPCISelLowering.cpp | |
parent | 7e3d9698fd425200f19410d4302eca5b4e821b9c (diff) | |
download | bcm5719-llvm-2db29ef4677b20b250cd75ab889281aed2f12705.tar.gz bcm5719-llvm-2db29ef4677b20b250cd75ab889281aed2f12705.zip |
[PowerPC] Fix PR16556 (handle undef ppcf128 in LowerFP_TO_INT).
PPCTargetLowering::LowerFP_TO_INT() expects its source operand to be
either an f32 or f64, but this is not checked. A long double
(ppcf128) operand will normally be custom-lowered to a conversion to
f64 in this context. However, this isn't the case for an UNDEF node.
This patch recognizes a ppcf128 as a legal source operand for
FP_TO_INT only if it's an undef, in which case it creates an undef of
the target type.
At some point we might want to do a wholesale custom lowering of
ISD::UNDEF when the type is ppcf128, but it's not really clear that's
a great idea, and probably more work than it's worth for a situation
that only arises in the case of a programming error. At this point I
think simple is best.
The test case comes from PR16556, and is a crash-test only.
llvm-svn: 185821
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 0f790313638..9c2856f24a4 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -4685,6 +4685,15 @@ SDValue PPCTargetLowering::LowerFP_TO_INT(SDValue Op, SelectionDAG &DAG, SDLoc dl) const { assert(Op.getOperand(0).getValueType().isFloatingPoint()); SDValue Src = Op.getOperand(0); + + // If we have a long double here, it must be that we have an undef of + // that type. In this case return an undef of the target type. + if (Src.getValueType() == MVT::ppcf128) { + assert(Src.getOpcode() == ISD::UNDEF && "Unhandled ppcf128!"); + return DAG.getNode(ISD::UNDEF, dl, + Op.getValueType().getSimpleVT().SimpleTy); + } + if (Src.getValueType() == MVT::f32) Src = DAG.getNode(ISD::FP_EXTEND, dl, MVT::f64, Src); |