Skip to content

Commit 0ef7902

Browse files
Varnikeaadeshps-mcw
authored andcommitted
[Mips] Set custom lowering for STRICT_FSETCC/STRICT_FSETCCS ops. (llvm#168303)
1 parent de52bc4 commit 0ef7902

File tree

3 files changed

+615
-1
lines changed

3 files changed

+615
-1
lines changed

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
359359
setOperationAction(ISD::STRICT_FP_TO_SINT, MVT::i32, Custom);
360360
setOperationAction(ISD::STRICT_FP_TO_UINT, MVT::i32, Custom);
361361

362+
setOperationAction(ISD::STRICT_FSETCC, MVT::f32, Custom);
363+
setOperationAction(ISD::STRICT_FSETCCS, MVT::f32, Custom);
364+
setOperationAction(ISD::STRICT_FSETCC, MVT::f64, Custom);
365+
setOperationAction(ISD::STRICT_FSETCCS, MVT::f64, Custom);
366+
362367
if (Subtarget.hasMips32r2() ||
363368
getTargetMachine().getTargetTriple().isOSLinux())
364369
setOperationAction(ISD::READCYCLECOUNTER, MVT::i64, Custom);
@@ -666,7 +671,8 @@ static bool invertFPCondCodeUser(Mips::CondCode CC) {
666671
// Returns Op if setcc is not a floating point comparison.
667672
static SDValue createFPCmp(SelectionDAG &DAG, const SDValue &Op) {
668673
// must be a SETCC node
669-
if (Op.getOpcode() != ISD::SETCC)
674+
if (Op.getOpcode() != ISD::SETCC && Op.getOpcode() != ISD::STRICT_FSETCC &&
675+
Op.getOpcode() != ISD::STRICT_FSETCCS)
670676
return Op;
671677

672678
SDValue LHS = Op.getOperand(0);
@@ -1343,6 +1349,9 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const
13431349
case ISD::JumpTable: return lowerJumpTable(Op, DAG);
13441350
case ISD::SELECT: return lowerSELECT(Op, DAG);
13451351
case ISD::SETCC: return lowerSETCC(Op, DAG);
1352+
case ISD::STRICT_FSETCC:
1353+
case ISD::STRICT_FSETCCS:
1354+
return lowerFSETCC(Op, DAG);
13461355
case ISD::VASTART: return lowerVASTART(Op, DAG);
13471356
case ISD::VAARG: return lowerVAARG(Op, DAG);
13481357
case ISD::FCOPYSIGN: return lowerFCOPYSIGN(Op, DAG);
@@ -2235,6 +2244,24 @@ SDValue MipsTargetLowering::lowerSETCC(SDValue Op, SelectionDAG &DAG) const {
22352244
return createCMovFP(DAG, Cond, True, False, DL);
22362245
}
22372246

2247+
SDValue MipsTargetLowering::lowerFSETCC(SDValue Op, SelectionDAG &DAG) const {
2248+
assert(!Subtarget.hasMips32r6() && !Subtarget.hasMips64r6());
2249+
2250+
SDLoc DL(Op);
2251+
SDValue Chain = Op.getOperand(0);
2252+
SDValue LHS = Op.getOperand(1);
2253+
SDValue RHS = Op.getOperand(2);
2254+
ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(3))->get();
2255+
2256+
SDValue Cond = DAG.getNode(MipsISD::FPCmp, DL, MVT::Glue, LHS, RHS,
2257+
DAG.getConstant(condCodeToFCC(CC), DL, MVT::i32));
2258+
SDValue True = DAG.getConstant(1, DL, MVT::i32);
2259+
SDValue False = DAG.getConstant(0, DL, MVT::i32);
2260+
SDValue CMovFP = createCMovFP(DAG, Cond, True, False, DL);
2261+
2262+
return DAG.getMergeValues({CMovFP, Chain}, DL);
2263+
}
2264+
22382265
SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
22392266
SelectionDAG &DAG) const {
22402267
EVT Ty = Op.getValueType();

llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ class TargetRegisterClass;
572572
SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
573573
SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
574574
SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
575+
SDValue lowerFSETCC(SDValue Op, SelectionDAG &DAG) const;
575576
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
576577
SDValue lowerVAARG(SDValue Op, SelectionDAG &DAG) const;
577578
SDValue lowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;

0 commit comments

Comments
 (0)