@@ -5529,19 +5529,6 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
5529
5529
if (VT == MVT::f128 && C->getValueType (0 ) == MVT::i128 )
5530
5530
return getConstantFP (APFloat (APFloat::IEEEquad (), Val), DL, VT);
5531
5531
break ;
5532
- case ISD::FP16_TO_FP:
5533
- case ISD::BF16_TO_FP: {
5534
- bool Ignored;
5535
- APFloat FPV (Opcode == ISD::FP16_TO_FP ? APFloat::IEEEhalf ()
5536
- : APFloat::BFloat (),
5537
- (Val.getBitWidth () == 16 ) ? Val : Val.trunc (16 ));
5538
-
5539
- // This can return overflow, underflow, or inexact; we don't care.
5540
- // FIXME need to be more flexible about rounding mode.
5541
- (void )FPV.convert (EVTToAPFloatSemantics (VT),
5542
- APFloat::rmNearestTiesToEven, &Ignored);
5543
- return getConstantFP (FPV, DL, VT);
5544
- }
5545
5532
case ISD::STEP_VECTOR: {
5546
5533
if (SDValue V = FoldSTEP_VECTOR (DL, VT, N1, *this ))
5547
5534
return V;
@@ -5564,16 +5551,6 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
5564
5551
if (VT == MVT::i64 && C->getValueType (0 ) == MVT::f64 )
5565
5552
return getConstant (V.bitcastToAPInt ().getZExtValue (), DL, VT);
5566
5553
break ;
5567
- case ISD::FP_TO_FP16:
5568
- case ISD::FP_TO_BF16: {
5569
- bool Ignored;
5570
- // This can return overflow, underflow, or inexact; we don't care.
5571
- // FIXME need to be more flexible about rounding mode.
5572
- (void )V.convert (Opcode == ISD::FP_TO_FP16 ? APFloat::IEEEhalf ()
5573
- : APFloat::BFloat (),
5574
- APFloat::rmNearestTiesToEven, &Ignored);
5575
- return getConstant (V.bitcastToAPInt ().getZExtValue (), DL, VT);
5576
- }
5577
5554
}
5578
5555
}
5579
5556
@@ -5591,12 +5568,16 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
5591
5568
case ISD::FP_EXTEND:
5592
5569
case ISD::FP_TO_SINT:
5593
5570
case ISD::FP_TO_UINT:
5571
+ case ISD::FP_TO_FP16:
5572
+ case ISD::FP_TO_BF16:
5594
5573
case ISD::TRUNCATE:
5595
5574
case ISD::ANY_EXTEND:
5596
5575
case ISD::ZERO_EXTEND:
5597
5576
case ISD::SIGN_EXTEND:
5598
5577
case ISD::UINT_TO_FP:
5599
5578
case ISD::SINT_TO_FP:
5579
+ case ISD::FP16_TO_FP:
5580
+ case ISD::BF16_TO_FP:
5600
5581
case ISD::ABS:
5601
5582
case ISD::BITREVERSE:
5602
5583
case ISD::BSWAP:
@@ -6109,6 +6090,19 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
6109
6090
APFloat::rmNearestTiesToEven);
6110
6091
return getConstantFP (apf, DL, VT);
6111
6092
}
6093
+ case ISD::FP16_TO_FP:
6094
+ case ISD::BF16_TO_FP: {
6095
+ bool Ignored;
6096
+ APFloat FPV (Opcode == ISD::FP16_TO_FP ? APFloat::IEEEhalf ()
6097
+ : APFloat::BFloat (),
6098
+ (Val.getBitWidth () == 16 ) ? Val : Val.trunc (16 ));
6099
+
6100
+ // This can return overflow, underflow, or inexact; we don't care.
6101
+ // FIXME need to be more flexible about rounding mode.
6102
+ (void )FPV.convert (EVTToAPFloatSemantics (VT),
6103
+ APFloat::rmNearestTiesToEven, &Ignored);
6104
+ return getConstantFP (FPV, DL, VT);
6105
+ }
6112
6106
}
6113
6107
}
6114
6108
@@ -6159,6 +6153,16 @@ SDValue SelectionDAG::FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
6159
6153
break ;
6160
6154
return getConstant (IntVal, DL, VT);
6161
6155
}
6156
+ case ISD::FP_TO_FP16:
6157
+ case ISD::FP_TO_BF16: {
6158
+ bool Ignored;
6159
+ // This can return overflow, underflow, or inexact; we don't care.
6160
+ // FIXME need to be more flexible about rounding mode.
6161
+ (void )V.convert (Opcode == ISD::FP_TO_FP16 ? APFloat::IEEEhalf ()
6162
+ : APFloat::BFloat (),
6163
+ APFloat::rmNearestTiesToEven, &Ignored);
6164
+ return getConstant (V.bitcastToAPInt ().getZExtValue (), DL, VT);
6165
+ }
6162
6166
}
6163
6167
}
6164
6168
}
0 commit comments