@@ -5519,15 +5519,6 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
5519
5519
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N1)) {
5520
5520
const APInt &Val = C->getAPIntValue ();
5521
5521
switch (Opcode) {
5522
- case ISD::UINT_TO_FP:
5523
- case ISD::SINT_TO_FP: {
5524
- APFloat apf (EVTToAPFloatSemantics (VT),
5525
- APInt::getZero (VT.getSizeInBits ()));
5526
- (void )apf.convertFromAPInt (Val,
5527
- Opcode==ISD::SINT_TO_FP,
5528
- APFloat::rmNearestTiesToEven);
5529
- return getConstantFP (apf, DL, VT);
5530
- }
5531
5522
case ISD::BITCAST:
5532
5523
if (VT == MVT::f16 && C->getValueType (0 ) == MVT::i16 )
5533
5524
return getConstantFP (APFloat (APFloat::IEEEhalf (), Val), DL, VT);
@@ -5563,17 +5554,6 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
5563
5554
if (ConstantFPSDNode *C = dyn_cast<ConstantFPSDNode>(N1)) {
5564
5555
APFloat V = C->getValueAPF (); // make copy
5565
5556
switch (Opcode) {
5566
- case ISD::FP_TO_SINT:
5567
- case ISD::FP_TO_UINT: {
5568
- bool ignored;
5569
- APSInt IntVal (VT.getSizeInBits (), Opcode == ISD::FP_TO_UINT);
5570
- // FIXME need to be more flexible about rounding mode.
5571
- APFloat::opStatus s =
5572
- V.convertToInteger (IntVal, APFloat::rmTowardZero, &ignored);
5573
- if (s == APFloat::opInvalidOp) // inexact is OK, in fact usual
5574
- break ;
5575
- return getConstant (IntVal, DL, VT);
5576
- }
5577
5557
case ISD::BITCAST:
5578
5558
if (VT == MVT::i16 && C->getValueType (0 ) == MVT::f16 )
5579
5559
return getConstant ((uint16_t )V.bitcastToAPInt ().getZExtValue (), DL, VT);
@@ -6121,6 +6101,14 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
6121
6101
case ISD::CTTZ_ZERO_UNDEF:
6122
6102
return getConstant (Val.countr_zero (), DL, VT, C->isTargetOpcode (),
6123
6103
C->isOpaque ());
6104
+ case ISD::UINT_TO_FP:
6105
+ case ISD::SINT_TO_FP: {
6106
+ APFloat apf (EVTToAPFloatSemantics (VT),
6107
+ APInt::getZero (VT.getSizeInBits ()));
6108
+ (void )apf.convertFromAPInt (Val, Opcode == ISD::SINT_TO_FP,
6109
+ APFloat::rmNearestTiesToEven);
6110
+ return getConstantFP (apf, DL, VT);
6111
+ }
6124
6112
}
6125
6113
}
6126
6114
@@ -6160,6 +6148,17 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
6160
6148
&ignored);
6161
6149
return getConstantFP (V, DL, VT);
6162
6150
}
6151
+ case ISD::FP_TO_SINT:
6152
+ case ISD::FP_TO_UINT: {
6153
+ bool ignored;
6154
+ APSInt IntVal (VT.getSizeInBits (), Opcode == ISD::FP_TO_UINT);
6155
+ // FIXME need to be more flexible about rounding mode.
6156
+ APFloat::opStatus s =
6157
+ V.convertToInteger (IntVal, APFloat::rmTowardZero, &ignored);
6158
+ if (s == APFloat::opInvalidOp) // inexact is OK, in fact usual
6159
+ break ;
6160
+ return getConstant (IntVal, DL, VT);
6161
+ }
6163
6162
}
6164
6163
}
6165
6164
}
0 commit comments