@@ -3578,15 +3578,22 @@ SDValue AMDGPUTargetLowering::LowerFP_TO_FP16(SDValue Op, SelectionDAG &DAG) con
3578
3578
return SDValue ();
3579
3579
}
3580
3580
3581
- assert (N0.getSimpleValueType () == MVT::f64 );
3581
+ return LowerF64ToF16 (N0, Op.getValueType (), DL, DAG);
3582
+ }
3583
+
3584
+ SDValue AMDGPUTargetLowering::LowerF64ToF16 (SDValue Src, EVT ResTy,
3585
+ const SDLoc &DL,
3586
+ SelectionDAG &DAG) const {
3587
+ assert (Src.getSimpleValueType () == MVT::f64 );
3582
3588
3583
3589
// f64 -> f16 conversion using round-to-nearest-even rounding mode.
3590
+ // TODO: We can generate better code for True16.
3584
3591
const unsigned ExpMask = 0x7ff ;
3585
3592
const unsigned ExpBiasf64 = 1023 ;
3586
3593
const unsigned ExpBiasf16 = 15 ;
3587
3594
SDValue Zero = DAG.getConstant (0 , DL, MVT::i32 );
3588
3595
SDValue One = DAG.getConstant (1 , DL, MVT::i32 );
3589
- SDValue U = DAG.getNode (ISD::BITCAST, DL, MVT::i64 , N0 );
3596
+ SDValue U = DAG.getNode (ISD::BITCAST, DL, MVT::i64 , Src );
3590
3597
SDValue UH = DAG.getNode (ISD::SRL, DL, MVT::i64 , U,
3591
3598
DAG.getConstant (32 , DL, MVT::i64 ));
3592
3599
UH = DAG.getZExtOrTrunc (UH, DL, MVT::i32 );
@@ -3661,7 +3668,7 @@ SDValue AMDGPUTargetLowering::LowerFP_TO_FP16(SDValue Op, SelectionDAG &DAG) con
3661
3668
DAG.getConstant (0x8000 , DL, MVT::i32 ));
3662
3669
3663
3670
V = DAG.getNode (ISD::OR, DL, MVT::i32 , Sign, V);
3664
- return DAG.getZExtOrTrunc (V, DL, Op. getValueType () );
3671
+ return DAG.getZExtOrTrunc (V, DL, ResTy );
3665
3672
}
3666
3673
3667
3674
SDValue AMDGPUTargetLowering::LowerFP_TO_INT (const SDValue Op,
0 commit comments