@@ -799,7 +799,7 @@ MVT SystemZTargetLowering::getRegisterTypeForCallingConv(
799
799
if (VT.isVector () && VT.getSizeInBits () == 128 &&
800
800
VT.getVectorNumElements () == 1 )
801
801
return MVT::v16i8;
802
- // Keep f16 so that they can be recognized and handled.
802
+ // Keep f16 so it can be recognized and handled.
803
803
if (VT == MVT::f16)
804
804
return MVT::f16;
805
805
return TargetLowering::getRegisterTypeForCallingConv (Context, CC, VT);
@@ -1625,10 +1625,13 @@ bool SystemZTargetLowering::splitValueIntoRegisterParts(
1625
1625
1626
1626
// Convert f16 to f32 (Out-arg).
1627
1627
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));
1632
1635
return true ;
1633
1636
}
1634
1637
@@ -1654,9 +1657,13 @@ static SDValue convertF32ToF16(SDValue F32Val, SelectionDAG &DAG,
1654
1657
const SDLoc &DL) {
1655
1658
assert (F32Val->getOpcode () == ISD::CopyFromReg &&
1656
1659
" 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));
1660
1667
}
1661
1668
1662
1669
SDValue SystemZTargetLowering::LowerFormalArguments (
0 commit comments