forked from OSchip/llvm-project
Fix a few instances found in SelectionDAG where we were not handling F16 at parity with F32 and F64.
llvm-svn: 223760
This commit is contained in:
parent
00a4da73d5
commit
558012a3fc
|
@ -6651,7 +6651,6 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
|
||||||
if (SrcEltVT.isFloatingPoint()) {
|
if (SrcEltVT.isFloatingPoint()) {
|
||||||
// Convert the input float vector to a int vector where the elements are the
|
// Convert the input float vector to a int vector where the elements are the
|
||||||
// same sizes.
|
// same sizes.
|
||||||
assert((SrcEltVT == MVT::f32 || SrcEltVT == MVT::f64) && "Unknown FP VT!");
|
|
||||||
EVT IntVT = EVT::getIntegerVT(*DAG.getContext(), SrcEltVT.getSizeInBits());
|
EVT IntVT = EVT::getIntegerVT(*DAG.getContext(), SrcEltVT.getSizeInBits());
|
||||||
BV = ConstantFoldBITCASTofBUILD_VECTOR(BV, IntVT).getNode();
|
BV = ConstantFoldBITCASTofBUILD_VECTOR(BV, IntVT).getNode();
|
||||||
SrcEltVT = IntVT;
|
SrcEltVT = IntVT;
|
||||||
|
@ -6660,7 +6659,6 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
|
||||||
// Now we know the input is an integer vector. If the output is a FP type,
|
// Now we know the input is an integer vector. If the output is a FP type,
|
||||||
// convert to integer first, then to FP of the right size.
|
// convert to integer first, then to FP of the right size.
|
||||||
if (DstEltVT.isFloatingPoint()) {
|
if (DstEltVT.isFloatingPoint()) {
|
||||||
assert((DstEltVT == MVT::f32 || DstEltVT == MVT::f64) && "Unknown FP VT!");
|
|
||||||
EVT TmpVT = EVT::getIntegerVT(*DAG.getContext(), DstEltVT.getSizeInBits());
|
EVT TmpVT = EVT::getIntegerVT(*DAG.getContext(), DstEltVT.getSizeInBits());
|
||||||
SDNode *Tmp = ConstantFoldBITCASTofBUILD_VECTOR(BV, TmpVT).getNode();
|
SDNode *Tmp = ConstantFoldBITCASTofBUILD_VECTOR(BV, TmpVT).getNode();
|
||||||
|
|
||||||
|
|
|
@ -2683,6 +2683,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL,
|
||||||
return getConstantFP(apf, VT);
|
return getConstantFP(apf, VT);
|
||||||
}
|
}
|
||||||
case ISD::BITCAST:
|
case ISD::BITCAST:
|
||||||
|
if (VT == MVT::f16 && C->getValueType(0) == MVT::i16)
|
||||||
|
return getConstantFP(APFloat(APFloat::IEEEhalf, Val), VT);
|
||||||
if (VT == MVT::f32 && C->getValueType(0) == MVT::i32)
|
if (VT == MVT::f32 && C->getValueType(0) == MVT::i32)
|
||||||
return getConstantFP(APFloat(APFloat::IEEEsingle, Val), VT);
|
return getConstantFP(APFloat(APFloat::IEEEsingle, Val), VT);
|
||||||
else if (VT == MVT::f64 && C->getValueType(0) == MVT::i64)
|
else if (VT == MVT::f64 && C->getValueType(0) == MVT::i64)
|
||||||
|
@ -2756,7 +2758,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL,
|
||||||
return getConstant(api, VT);
|
return getConstant(api, VT);
|
||||||
}
|
}
|
||||||
case ISD::BITCAST:
|
case ISD::BITCAST:
|
||||||
if (VT == MVT::i32 && C->getValueType(0) == MVT::f32)
|
if (VT == MVT::i16 && C->getValueType(0) == MVT::f16)
|
||||||
|
return getConstant((uint16_t)V.bitcastToAPInt().getZExtValue(), VT);
|
||||||
|
else if (VT == MVT::i32 && C->getValueType(0) == MVT::f32)
|
||||||
return getConstant((uint32_t)V.bitcastToAPInt().getZExtValue(), VT);
|
return getConstant((uint32_t)V.bitcastToAPInt().getZExtValue(), VT);
|
||||||
else if (VT == MVT::i64 && C->getValueType(0) == MVT::f64)
|
else if (VT == MVT::i64 && C->getValueType(0) == MVT::f64)
|
||||||
return getConstant(V.bitcastToAPInt().getZExtValue(), VT);
|
return getConstant(V.bitcastToAPInt().getZExtValue(), VT);
|
||||||
|
|
Loading…
Reference in New Issue