Skip to content

Commit e2e180b

Browse files
committed
Use setCondCodeAction and getCondCodeAction
1 parent bd37d0b commit e2e180b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8424,6 +8424,12 @@ TargetLowering::createSelectForFMINNUM_FMAXNUM(SDNode *Node,
84248424

84258425
if (Node->getFlags().hasNoNaNs()) {
84268426
ISD::CondCode Pred = Opcode == ISD::FMINNUM ? ISD::SETLT : ISD::SETGT;
8427+
EVT VT = Node->getValueType(0);
8428+
if ((!isCondCodeLegal(Pred, VT.getSimpleVT()) ||
8429+
!isOperationLegalOrCustom(ISD::VSELECT, VT)) &&
8430+
VT.isVector() &&
8431+
isOperationLegal(Node->getOpcode(), VT.getScalarType()))
8432+
return SDValue();
84278433
SDValue Op1 = Node->getOperand(0);
84288434
SDValue Op2 = Node->getOperand(1);
84298435
SDValue SelCC = DAG.getSelectCC(SDLoc(Node), Op1, Op2, Op1, Op2, Pred);
@@ -8485,11 +8491,6 @@ SDValue TargetLowering::expandFMINNUM_FMAXNUM(SDNode *Node,
84858491
Node->getOperand(1), Node->getFlags());
84868492
}
84878493

8488-
// If we have INSN fitting this operation strictly for the elements of the
8489-
// vector, normally, splitting it is better than compare+select.
8490-
if (VT.isVector() && isOperationLegal(Node->getOpcode(), VT.getScalarType()))
8491-
return SDValue();
8492-
84938494
if (SDValue SelCC = createSelectForFMINNUM_FMAXNUM(Node, DAG))
84948495
return SelCC;
84958496

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,10 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
894894
setOperationAction(ISD::FNEARBYINT, MVT::v2f64, Expand);
895895
setOperationAction(ISD::FFLOOR, MVT::v2f64, Expand);
896896
setOperationAction(ISD::FMA, MVT::v2f64, Expand);
897+
898+
for (auto CC : {ISD::SETOGT, ISD::SETOGE, ISD::SETOLT, ISD::SETOLE,
899+
ISD::SETGT, ISD::SETGE, ISD::SETLT, ISD::SETLE})
900+
setCondCodeAction(CC, MVT::v2f64, Expand);
897901
}
898902

899903
if (Subtarget->hasNEON()) {
@@ -915,6 +919,9 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
915919
setOperationAction(ISD::FRINT, MVT::v4f32, Expand);
916920
setOperationAction(ISD::FNEARBYINT, MVT::v4f32, Expand);
917921
setOperationAction(ISD::FFLOOR, MVT::v4f32, Expand);
922+
for (auto CC : {ISD::SETOGT, ISD::SETOGE, ISD::SETOLT, ISD::SETOLE,
923+
ISD::SETGT, ISD::SETGE, ISD::SETLT, ISD::SETLE})
924+
setCondCodeAction(CC, MVT::v4f32, Expand);
918925

919926
// Mark v2f32 intrinsics.
920927
setOperationAction(ISD::FSQRT, MVT::v2f32, Expand);
@@ -933,6 +940,9 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM,
933940
setOperationAction(ISD::FRINT, MVT::v2f32, Expand);
934941
setOperationAction(ISD::FNEARBYINT, MVT::v2f32, Expand);
935942
setOperationAction(ISD::FFLOOR, MVT::v2f32, Expand);
943+
for (auto CC : {ISD::SETOGT, ISD::SETOGE, ISD::SETOLT, ISD::SETOLE,
944+
ISD::SETGT, ISD::SETGE, ISD::SETLT, ISD::SETLE})
945+
setCondCodeAction(CC, MVT::v2f32, Expand);
936946

937947
// Neon does not support some operations on v1i64 and v2i64 types.
938948
setOperationAction(ISD::MUL, MVT::v1i64, Expand);

0 commit comments

Comments
 (0)