@@ -799,7 +799,7 @@ MVT SystemZTargetLowering::getRegisterTypeForCallingConv(
799799 if (VT.isVector () && VT.getSizeInBits () == 128 &&
800800 VT.getVectorNumElements () == 1 )
801801 return MVT::v16i8;
802- // Keep f16 so that they can be recognized and handled.
802+ // Keep f16 so it can be recognized and handled.
803803 if (VT == MVT::f16 )
804804 return MVT::f16 ;
805805 return TargetLowering::getRegisterTypeForCallingConv (Context, CC, VT);
@@ -1625,10 +1625,13 @@ bool SystemZTargetLowering::splitValueIntoRegisterParts(
16251625
16261626 // Convert f16 to f32 (Out-arg).
16271627 if (PartVT == MVT::f16 ) {
1628- assert (NumParts == 1 && " " );
1629- SDValue I16Val = DAG.getBitcast (MVT::i16 , Val);
1630- SDValue I32Val = DAG.getAnyExtOrTrunc (I16Val, DL, MVT::i32 );
1631- Parts[0 ] = DAG.getBitcast (MVT::f32 , I32Val);
1628+ assert (NumParts == 1 && " f16 only needs one register." );
1629+ SDValue F16Vec = DAG.getNode (ISD::INSERT_VECTOR_ELT, DL, MVT::v8f16,
1630+ DAG.getUNDEF (MVT::v8f16), Val,
1631+ DAG.getVectorIdxConstant (0 , DL));
1632+ SDValue F32Vec = DAG.getBitcast (MVT::v4f32, F16Vec);
1633+ Parts[0 ] = DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, MVT::f32 ,
1634+ F32Vec, DAG.getVectorIdxConstant (0 , DL));
16321635 return true ;
16331636 }
16341637
@@ -1654,9 +1657,13 @@ static SDValue convertF32ToF16(SDValue F32Val, SelectionDAG &DAG,
16541657 const SDLoc &DL) {
16551658 assert (F32Val->getOpcode () == ISD::CopyFromReg &&
16561659 " Only expecting to handle f16 with CopyFromReg here." );
1657- SDValue I32Val = DAG.getBitcast (MVT::i32 , F32Val);
1658- SDValue I16Val = DAG.getAnyExtOrTrunc (I32Val, DL, MVT::i16 );
1659- return DAG.getBitcast (MVT::f16 , I16Val);
1660+
1661+ SDValue F32Vec = DAG.getNode (ISD::INSERT_VECTOR_ELT, DL, MVT::v4f32,
1662+ DAG.getUNDEF (MVT::v4f32), F32Val,
1663+ DAG.getVectorIdxConstant (0 , DL));
1664+ SDValue F16Vec = DAG.getBitcast (MVT::v8f16, F32Vec);
1665+ return DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, MVT::f16 ,
1666+ F16Vec, DAG.getVectorIdxConstant (0 , DL));
16601667}
16611668
16621669SDValue SystemZTargetLowering::LowerFormalArguments (
0 commit comments