@@ -881,6 +881,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
881881 }
882882
883883 unsigned getCmpSelInstrCost (unsigned Opcode, Type *ValTy, Type *CondTy,
884+ CmpInst::Predicate VecPred,
884885 TTI::TargetCostKind CostKind,
885886 const Instruction *I = nullptr ) {
886887 const TargetLoweringBase *TLI = getTLI ();
@@ -889,7 +890,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
889890
890891 // TODO: Handle other cost kinds.
891892 if (CostKind != TTI::TCK_RecipThroughput)
892- return BaseT::getCmpSelInstrCost (Opcode, ValTy, CondTy, CostKind, I);
893+ return BaseT::getCmpSelInstrCost (Opcode, ValTy, CondTy, VecPred, CostKind,
894+ I);
893895
894896 // Selects on vectors are actually vector selects.
895897 if (ISD == ISD::SELECT) {
@@ -914,7 +916,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
914916 if (CondTy)
915917 CondTy = CondTy->getScalarType ();
916918 unsigned Cost = thisT ()->getCmpSelInstrCost (
917- Opcode, ValVTy->getScalarType (), CondTy, CostKind, I);
919+ Opcode, ValVTy->getScalarType (), CondTy, VecPred, CostKind, I);
918920
919921 // Return the cost of multiple scalar invocation plus the cost of
920922 // inserting and extracting the values.
@@ -1241,10 +1243,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
12411243 // For non-rotates (X != Y) we must add shift-by-zero handling costs.
12421244 if (X != Y) {
12431245 Type *CondTy = RetTy->getWithNewBitWidth (1 );
1244- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1245- CostKind);
1246- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy,
1247- CondTy, CostKind);
1246+ Cost +=
1247+ thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1248+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
1249+ Cost +=
1250+ thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
1251+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
12481252 }
12491253 return Cost;
12501254 }
@@ -1483,10 +1487,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14831487 Type *CondTy = RetTy->getWithNewBitWidth (1 );
14841488 unsigned Cost = 0 ;
14851489 // TODO: Ideally getCmpSelInstrCost would accept an icmp condition code.
1486- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1487- CostKind);
1488- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
1489- CostKind);
1490+ Cost +=
1491+ thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1492+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
1493+ Cost +=
1494+ thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
1495+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
14901496 // TODO: Should we add an OperandValueProperties::OP_Zero property?
14911497 if (IID == Intrinsic::abs)
14921498 Cost += thisT ()->getArithmeticInstrCost (
@@ -1508,10 +1514,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15081514 IntrinsicCostAttributes Attrs (OverflowOp, OpTy, {RetTy, RetTy}, FMF,
15091515 ScalarizationCostPassed);
15101516 Cost += thisT ()->getIntrinsicInstrCost (Attrs, CostKind);
1511- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1512- CostKind);
1513- Cost += 2 * thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy,
1514- CondTy, CostKind);
1517+ Cost +=
1518+ thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
1519+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
1520+ Cost += 2 * thisT ()->getCmpSelInstrCost (
1521+ BinaryOperator::Select, RetTy, CondTy,
1522+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
15151523 return Cost;
15161524 }
15171525 case Intrinsic::uadd_sat:
@@ -1527,8 +1535,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15271535 IntrinsicCostAttributes Attrs (OverflowOp, OpTy, {RetTy, RetTy}, FMF,
15281536 ScalarizationCostPassed);
15291537 Cost += thisT ()->getIntrinsicInstrCost (Attrs, CostKind);
1530- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
1531- CostKind);
1538+ Cost +=
1539+ thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
1540+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
15321541 return Cost;
15331542 }
15341543 case Intrinsic::smul_fix:
@@ -1573,10 +1582,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15731582 // Overflow -> (LHSSign != RHSSign) && (LHSSign != SumSign)
15741583 unsigned Cost = 0 ;
15751584 Cost += thisT ()->getArithmeticInstrCost (Opcode, SumTy, CostKind);
1576- Cost += 3 * thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, SumTy,
1577- OverflowTy, CostKind);
1578- Cost += 2 * thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, OverflowTy,
1579- OverflowTy, CostKind);
1585+ Cost += 3 * thisT ()->getCmpSelInstrCost (
1586+ BinaryOperator::ICmp, SumTy, OverflowTy,
1587+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
1588+ Cost += 2 * thisT ()->getCmpSelInstrCost (
1589+ BinaryOperator::ICmp, OverflowTy, OverflowTy,
1590+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
15801591 Cost += thisT ()->getArithmeticInstrCost (BinaryOperator::And, OverflowTy,
15811592 CostKind);
15821593 return Cost;
@@ -1591,8 +1602,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15911602
15921603 unsigned Cost = 0 ;
15931604 Cost += thisT ()->getArithmeticInstrCost (Opcode, SumTy, CostKind);
1594- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, SumTy,
1595- OverflowTy, CostKind);
1605+ Cost +=
1606+ thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, SumTy, OverflowTy,
1607+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
15961608 return Cost;
15971609 }
15981610 case Intrinsic::smul_with_overflow:
@@ -1621,8 +1633,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
16211633 CostKind, TTI::OK_AnyValue,
16221634 TTI::OK_UniformConstantValue);
16231635
1624- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, MulTy,
1625- OverflowTy, CostKind);
1636+ Cost +=
1637+ thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, MulTy, OverflowTy,
1638+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
16261639 return Cost;
16271640 }
16281641 case Intrinsic::ctpop:
@@ -1864,9 +1877,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
18641877 (IsPairwise + 1 ) * thisT ()->getShuffleCost (TTI::SK_ExtractSubvector,
18651878 Ty, NumVecElts, SubTy);
18661879 MinMaxCost +=
1867- thisT ()->getCmpSelInstrCost (CmpOpcode, SubTy, CondTy, CostKind) +
1880+ thisT ()->getCmpSelInstrCost (CmpOpcode, SubTy, CondTy,
1881+ CmpInst::BAD_ICMP_PREDICATE, CostKind) +
18681882 thisT ()->getCmpSelInstrCost (Instruction::Select, SubTy, CondTy,
1869- CostKind);
1883+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
18701884 Ty = SubTy;
18711885 ++LongVectorCount;
18721886 }
@@ -1888,9 +1902,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
18881902 thisT ()->getShuffleCost (TTI::SK_PermuteSingleSrc, Ty, 0 , Ty);
18891903 MinMaxCost +=
18901904 NumReduxLevels *
1891- (thisT ()->getCmpSelInstrCost (CmpOpcode, Ty, CondTy, CostKind) +
1905+ (thisT ()->getCmpSelInstrCost (CmpOpcode, Ty, CondTy,
1906+ CmpInst::BAD_ICMP_PREDICATE, CostKind) +
18921907 thisT ()->getCmpSelInstrCost (Instruction::Select, Ty, CondTy,
1893- CostKind));
1908+ CmpInst::BAD_ICMP_PREDICATE, CostKind));
18941909 // The last min/max should be in vector registers and we counted it above.
18951910 // So just need a single extractelement.
18961911 return ShuffleCost + MinMaxCost +
0 commit comments