4223  4223 
return SDValue();

4224  4224 

4225  4225 
if (Op.getOperand(0).getValueType() == MVT::i64) {

4226  
SDValue Bits = DAG.getNode(ISD::BITCAST, dl, MVT::f64, Op.getOperand(0));⏎

 4226 
SDValue SINT = Op.getOperand(0);⏎

 4227 
// When converting to singleprecision, we actually need to convert

 4228 
// to doubleprecision first and then round to singleprecision.

 4229 
// To avoid doublerounding effects during that operation, we have

 4230 
// to prepare the input operand. Bits that might be truncated when

 4231 
// converting to doubleprecision are replaced by a bit that won't

 4232 
// be lost at this stage, but is below the singleprecision rounding

 4233 
// position.

 4234 
//

 4235 
// However, if enableunsafefpmath is in effect, accept double

 4236 
// rounding to avoid the extra overhead.

 4237 
if (Op.getValueType() == MVT::f32 &&

 4238 
!DAG.getTarget().Options.UnsafeFPMath) {

 4239 

 4240 
// Twiddle input to make sure the low 11 bits are zero. (If this

 4241 
// is the case, we are guaranteed the value will fit into the 53 bit

 4242 
// mantissa of an IEEE doubleprecision value without rounding.)

 4243 
// If any of those low 11 bits were not zero originally, make sure

 4244 
// bit 12 (value 2048) is set instead, so that the final rounding

 4245 
// to singleprecision gets the correct result.

 4246 
SDValue Round = DAG.getNode(ISD::AND, dl, MVT::i64,

 4247 
SINT, DAG.getConstant(2047, MVT::i64));

 4248 
Round = DAG.getNode(ISD::ADD, dl, MVT::i64,

 4249 
Round, DAG.getConstant(2047, MVT::i64));

 4250 
Round = DAG.getNode(ISD::OR, dl, MVT::i64, Round, SINT);

 4251 
Round = DAG.getNode(ISD::AND, dl, MVT::i64,

 4252 
Round, DAG.getConstant(2048, MVT::i64));

 4253 

 4254 
// However, we cannot use that value unconditionally: if the magnitude

 4255 
// of the input value is small, the bittwiddling we did above might

 4256 
// end up visibly changing the output. Fortunately, in that case, we

 4257 
// don't need to twiddle bits since the original input will convert

 4258 
// exactly to doubleprecision floatingpoint already. Therefore,

 4259 
// construct a conditional to use the original value if the top 11

 4260 
// bits are all signbit copies, and use the rounded value computed

 4261 
// above otherwise.

 4262 
SDValue Cond = DAG.getNode(ISD::SRA, dl, MVT::i64,

 4263 
SINT, DAG.getConstant(53, MVT::i32));

 4264 
Cond = DAG.getNode(ISD::ADD, dl, MVT::i64,

 4265 
Cond, DAG.getConstant(1, MVT::i64));

 4266 
Cond = DAG.getSetCC(dl, MVT::i32,

 4267 
Cond, DAG.getConstant(1, MVT::i64), ISD::SETUGT);

 4268 

 4269 
SINT = DAG.getNode(ISD::SELECT, dl, MVT::i64, Cond, Round, SINT);

 4270 
}

 4271 
SDValue Bits = DAG.getNode(ISD::BITCAST, dl, MVT::f64, SINT);

4227  4272 
SDValue FP = DAG.getNode(PPCISD::FCFID, dl, MVT::f64, Bits);

4228  4273 
if (Op.getValueType() == MVT::f32)

4229  4274 
FP = DAG.getNode(ISD::FP_ROUND, dl,
