Skip to content

Commit e0898a0

Browse files
committed
Make new AArch64ISD nodes return f32
1 parent eed4fd2 commit e0898a0

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,8 @@ void AArch64DAGToDAGISel::SelectPostStoreLane(SDNode *N, unsigned NumVecs,
25382538
}
25392539

25402540
// Select f16 -> i16 conversions
2541-
// Since i16 is an illegal type, they need to return an i32 result
2541+
// Since i16 is an illegal type, we return the converted bit pattern in a f32
2542+
// which can then be bitcast to i32 and truncated as needed.
25422543
void AArch64DAGToDAGISel::SelectFCVT_FPTOINT_Half(SDNode *N, unsigned int Opc) {
25432544
SDLoc DL(N);
25442545
SDValue SrcVal = N->getOperand(0);
@@ -2551,9 +2552,7 @@ void AArch64DAGToDAGISel::SelectFCVT_FPTOINT_Half(SDNode *N, unsigned int Opc) {
25512552
SDNode *Extract =
25522553
CurDAG->getMachineNode(TargetOpcode::EXTRACT_SUBREG, DL, MVT::f32,
25532554
SDValue(SubregToReg, 0), Ssub);
2554-
SDNode *Result = CurDAG->getMachineNode(AArch64::FMOVSWr, DL, MVT::i32,
2555-
SDValue(Extract, 0));
2556-
ReplaceNode(N, Result);
2555+
ReplaceNode(N, Extract);
25572556
}
25582557

25592558
static bool isBitfieldExtractOpFromAnd(SelectionDAG *CurDAG, SDNode *N,

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4912,9 +4912,12 @@ SDValue AArch64TargetLowering::LowerFP_TO_INT_SAT(SDValue Op,
49124912
return SDValue();
49134913

49144914
if (SrcVT == MVT::f16 && SatVT == MVT::i16 && DstVT == MVT::i32) {
4915+
SDValue CVTf32;
49154916
if (Op.getOpcode() == ISD::FP_TO_SINT_SAT)
4916-
return DAG.getNode(AArch64ISD::FCVTZS_HALF, DL, DstVT, SrcVal);
4917-
return DAG.getNode(AArch64ISD::FCVTZU_HALF, DL, DstVT, SrcVal);
4917+
CVTf32 = DAG.getNode(AArch64ISD::FCVTZS_HALF, DL, MVT::f32, SrcVal);
4918+
else
4919+
CVTf32 = DAG.getNode(AArch64ISD::FCVTZU_HALF, DL, MVT::f32, SrcVal);
4920+
return DAG.getBitcast(DstVT, CVTf32);
49184921
}
49194922

49204923
SDValue NativeCvt =

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -989,8 +989,8 @@ def AArch64fcvtxnv: PatFrags<(ops node:$Rn),
989989
[(int_aarch64_neon_fcvtxn node:$Rn),
990990
(AArch64fcvtxn_n node:$Rn)]>;
991991

992-
def AArch64fcvtzs_half : SDNode<"AArch64ISD::FCVTZS_HALF", SDTFPToIntOp>;
993-
def AArch64fcvtzu_half : SDNode<"AArch64ISD::FCVTZU_HALF", SDTFPToIntOp>;
992+
def AArch64fcvtzs_half : SDNode<"AArch64ISD::FCVTZS_HALF", SDTFPExtendOp>;
993+
def AArch64fcvtzu_half : SDNode<"AArch64ISD::FCVTZU_HALF", SDTFPExtendOp>;
994994

995995
//def Aarch64softf32tobf16v8: SDNode<"AArch64ISD::", SDTFPRoundOp>;
996996

0 commit comments

Comments
 (0)