@@ -881,6 +881,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
881
881
}
882
882
883
883
unsigned getCmpSelInstrCost (unsigned Opcode, Type *ValTy, Type *CondTy,
884
+ CmpInst::Predicate VecPred,
884
885
TTI::TargetCostKind CostKind,
885
886
const Instruction *I = nullptr ) {
886
887
const TargetLoweringBase *TLI = getTLI ();
@@ -889,7 +890,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
889
890
890
891
// TODO: Handle other cost kinds.
891
892
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);
893
895
894
896
// Selects on vectors are actually vector selects.
895
897
if (ISD == ISD::SELECT) {
@@ -914,7 +916,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
914
916
if (CondTy)
915
917
CondTy = CondTy->getScalarType ();
916
918
unsigned Cost = thisT ()->getCmpSelInstrCost (
917
- Opcode, ValVTy->getScalarType (), CondTy, CostKind, I);
919
+ Opcode, ValVTy->getScalarType (), CondTy, VecPred, CostKind, I);
918
920
919
921
// Return the cost of multiple scalar invocation plus the cost of
920
922
// inserting and extracting the values.
@@ -1241,10 +1243,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1241
1243
// For non-rotates (X != Y) we must add shift-by-zero handling costs.
1242
1244
if (X != Y) {
1243
1245
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);
1248
1252
}
1249
1253
return Cost;
1250
1254
}
@@ -1483,10 +1487,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1483
1487
Type *CondTy = RetTy->getWithNewBitWidth (1 );
1484
1488
unsigned Cost = 0 ;
1485
1489
// 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);
1490
1496
// TODO: Should we add an OperandValueProperties::OP_Zero property?
1491
1497
if (IID == Intrinsic::abs )
1492
1498
Cost += thisT ()->getArithmeticInstrCost (
@@ -1508,10 +1514,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1508
1514
IntrinsicCostAttributes Attrs (OverflowOp, OpTy, {RetTy, RetTy}, FMF,
1509
1515
ScalarizationCostPassed);
1510
1516
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);
1515
1523
return Cost;
1516
1524
}
1517
1525
case Intrinsic::uadd_sat:
@@ -1527,8 +1535,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1527
1535
IntrinsicCostAttributes Attrs (OverflowOp, OpTy, {RetTy, RetTy}, FMF,
1528
1536
ScalarizationCostPassed);
1529
1537
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);
1532
1541
return Cost;
1533
1542
}
1534
1543
case Intrinsic::smul_fix:
@@ -1573,10 +1582,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1573
1582
// Overflow -> (LHSSign != RHSSign) && (LHSSign != SumSign)
1574
1583
unsigned Cost = 0 ;
1575
1584
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);
1580
1591
Cost += thisT ()->getArithmeticInstrCost (BinaryOperator::And, OverflowTy,
1581
1592
CostKind);
1582
1593
return Cost;
@@ -1591,8 +1602,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1591
1602
1592
1603
unsigned Cost = 0 ;
1593
1604
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);
1596
1608
return Cost;
1597
1609
}
1598
1610
case Intrinsic::smul_with_overflow:
@@ -1621,8 +1633,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1621
1633
CostKind, TTI::OK_AnyValue,
1622
1634
TTI::OK_UniformConstantValue);
1623
1635
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);
1626
1639
return Cost;
1627
1640
}
1628
1641
case Intrinsic::ctpop:
@@ -1864,9 +1877,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1864
1877
(IsPairwise + 1 ) * thisT ()->getShuffleCost (TTI::SK_ExtractSubvector,
1865
1878
Ty, NumVecElts, SubTy);
1866
1879
MinMaxCost +=
1867
- thisT ()->getCmpSelInstrCost (CmpOpcode, SubTy, CondTy, CostKind) +
1880
+ thisT ()->getCmpSelInstrCost (CmpOpcode, SubTy, CondTy,
1881
+ CmpInst::BAD_ICMP_PREDICATE, CostKind) +
1868
1882
thisT ()->getCmpSelInstrCost (Instruction::Select, SubTy, CondTy,
1869
- CostKind);
1883
+ CmpInst::BAD_ICMP_PREDICATE, CostKind);
1870
1884
Ty = SubTy;
1871
1885
++LongVectorCount;
1872
1886
}
@@ -1888,9 +1902,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1888
1902
thisT ()->getShuffleCost (TTI::SK_PermuteSingleSrc, Ty, 0 , Ty);
1889
1903
MinMaxCost +=
1890
1904
NumReduxLevels *
1891
- (thisT ()->getCmpSelInstrCost (CmpOpcode, Ty, CondTy, CostKind) +
1905
+ (thisT ()->getCmpSelInstrCost (CmpOpcode, Ty, CondTy,
1906
+ CmpInst::BAD_ICMP_PREDICATE, CostKind) +
1892
1907
thisT ()->getCmpSelInstrCost (Instruction::Select, Ty, CondTy,
1893
- CostKind));
1908
+ CmpInst::BAD_ICMP_PREDICATE, CostKind));
1894
1909
// The last min/max should be in vector registers and we counted it above.
1895
1910
// So just need a single extractelement.
1896
1911
return ShuffleCost + MinMaxCost +
0 commit comments