diff options
author | Dale Johannesen <dalej@apple.com> | 2008-11-12 18:38:44 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2008-11-12 18:38:44 +0000 |
commit | 7e298ed379d71c32d62cbfc6e8df8039b04ef895 (patch) | |
tree | 9096c07cbbbe4b70d2f8053aa415e89a3807886c /lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp | |
parent | 2d9716f7bfb701d4606a993765ea233116fe3a68 (diff) |
Fix unsigned char->ppcf128 conversion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp index 0e90ed29b6..9084e582da 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp @@ -919,17 +919,22 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, MVT NVT = TLI.getTypeToTransformTo(VT); SDValue Src = N->getOperand(0); MVT SrcVT = Src.getValueType(); + bool isSigned = N->getOpcode() == ISD::SINT_TO_FP; // First do an SINT_TO_FP, whether the original was signed or unsigned. + // When promoting partial word types to i32 we must honor the signedness, + // though. if (SrcVT.bitsLE(MVT::i32)) { // The integer can be represented exactly in an f64. - Src = DAG.getNode(ISD::SIGN_EXTEND, MVT::i32, Src); + Src = DAG.getNode(isSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, + MVT::i32, Src); Lo = DAG.getConstantFP(APFloat(APInt(NVT.getSizeInBits(), 0)), NVT); Hi = DAG.getNode(ISD::SINT_TO_FP, NVT, Src); } else { RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL; if (SrcVT.bitsLE(MVT::i64)) { - Src = DAG.getNode(ISD::SIGN_EXTEND, MVT::i64, Src); + Src = DAG.getNode(isSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, + MVT::i64, Src); LC = RTLIB::SINTTOFP_I64_PPCF128; } else if (SrcVT.bitsLE(MVT::i128)) { Src = DAG.getNode(ISD::SIGN_EXTEND, MVT::i128, Src); @@ -943,7 +948,7 @@ void DAGTypeLegalizer::ExpandFloatRes_XINT_TO_FP(SDNode *N, SDValue &Lo, Lo = Hi.getOperand(0); Hi = Hi.getOperand(1); } - if (N->getOpcode() == ISD::SINT_TO_FP) + if (isSigned) return; // Unsigned - fix up the SINT_TO_FP value just calculated. |