Skip to content

Commit 95414b9

Browse files
fhahnarichardson
authored andcommitted
[TTI] Add VecPred argument to getCmpSelInstrCost.
On some targets, like AArch64, vector selects can be efficiently lowered if the vector condition is a compare with a supported predicate. This patch adds a new argument to getCmpSelInstrCost, to indicate the predicate of the feeding select condition. Note that it is not sufficient to use the context instruction when querying the cost of a vector select starting from a scalar one, because the condition of the vector select could be composed of compares with different predicates. This change greatly improves modeling the costs of certain compare/select patterns on AArch64. I am also planning on putting up patches to make use of the new argument in SLPVectorizer & LV. Reviewed By: dmgreen, RKSimon Differential Revision: https://reviews.llvm.org/D90070
2 parents 5f4dcb3 + 73f01e3 commit 95414b9

21 files changed

+148
-78
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
2222
#define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
2323

24+
#include "llvm/IR/InstrTypes.h"
2425
#include "llvm/IR/Operator.h"
2526
#include "llvm/IR/PassManager.h"
2627
#include "llvm/Pass.h"
@@ -1092,10 +1093,14 @@ class TargetTransformInfo {
10921093

10931094
/// \returns The expected cost of compare and select instructions. If there
10941095
/// is an existing instruction that holds Opcode, it may be passed in the
1095-
/// 'I' parameter.
1096-
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy = nullptr,
1097-
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
1098-
const Instruction *I = nullptr) const;
1096+
/// 'I' parameter. The \p VecPred parameter can be used to indicate the select
1097+
/// is using a compare with the specified predicate as condition. When vector
1098+
/// types are passed, \p VecPred must be used for all lanes.
1099+
int getCmpSelInstrCost(
1100+
unsigned Opcode, Type *ValTy, Type *CondTy = nullptr,
1101+
CmpInst::Predicate VecPred = CmpInst::BAD_ICMP_PREDICATE,
1102+
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
1103+
const Instruction *I = nullptr) const;
10991104

11001105
/// \return The expected cost of vector Insert and Extract.
11011106
/// Use -1 to indicate that there is no information on the index value.
@@ -1534,6 +1539,7 @@ class TargetTransformInfo::Concept {
15341539
virtual int getCFInstrCost(unsigned Opcode,
15351540
TTI::TargetCostKind CostKind) = 0;
15361541
virtual int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
1542+
CmpInst::Predicate VecPred,
15371543
TTI::TargetCostKind CostKind,
15381544
const Instruction *I) = 0;
15391545
virtual int getVectorInstrCost(unsigned Opcode, Type *Val,
@@ -1975,9 +1981,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
19751981
return Impl.getCFInstrCost(Opcode, CostKind);
19761982
}
19771983
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
1984+
CmpInst::Predicate VecPred,
19781985
TTI::TargetCostKind CostKind,
19791986
const Instruction *I) override {
1980-
return Impl.getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
1987+
return Impl.getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
19811988
}
19821989
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) override {
19831990
return Impl.getVectorInstrCost(Opcode, Val, Index);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ class TargetTransformInfoImplBase {
478478
}
479479

480480
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
481+
CmpInst::Predicate VecPred,
481482
TTI::TargetCostKind CostKind,
482483
const Instruction *I) const {
483484
return 1;
@@ -947,12 +948,14 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
947948
case Instruction::Select: {
948949
Type *CondTy = U->getOperand(0)->getType();
949950
return TargetTTI->getCmpSelInstrCost(Opcode, U->getType(), CondTy,
951+
CmpInst::BAD_ICMP_PREDICATE,
950952
CostKind, I);
951953
}
952954
case Instruction::ICmp:
953955
case Instruction::FCmp: {
954956
Type *ValTy = U->getOperand(0)->getType();
955957
return TargetTTI->getCmpSelInstrCost(Opcode, ValTy, U->getType(),
958+
cast<CmpInst>(U)->getPredicate(),
956959
CostKind, I);
957960
}
958961
case Instruction::InsertElement: {

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
883883
}
884884

885885
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
886+
CmpInst::Predicate VecPred,
886887
TTI::TargetCostKind CostKind,
887888
const Instruction *I = nullptr) {
888889
const TargetLoweringBase *TLI = getTLI();
@@ -891,7 +892,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
891892

892893
// TODO: Handle other cost kinds.
893894
if (CostKind != TTI::TCK_RecipThroughput)
894-
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
895+
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
896+
I);
895897

896898
// Selects on vectors are actually vector selects.
897899
if (ISD == ISD::SELECT) {
@@ -916,7 +918,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
916918
if (CondTy)
917919
CondTy = CondTy->getScalarType();
918920
unsigned Cost = thisT()->getCmpSelInstrCost(
919-
Opcode, ValVTy->getScalarType(), CondTy, CostKind, I);
921+
Opcode, ValVTy->getScalarType(), CondTy, VecPred, CostKind, I);
920922

921923
// Return the cost of multiple scalar invocation plus the cost of
922924
// inserting and extracting the values.
@@ -1243,10 +1245,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
12431245
// For non-rotates (X != Y) we must add shift-by-zero handling costs.
12441246
if (X != Y) {
12451247
Type *CondTy = RetTy->getWithNewBitWidth(1);
1246-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1247-
CostKind);
1248-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy,
1249-
CondTy, CostKind);
1248+
Cost +=
1249+
thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1250+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
1251+
Cost +=
1252+
thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1253+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
12501254
}
12511255
return Cost;
12521256
}
@@ -1485,10 +1489,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
14851489
Type *CondTy = RetTy->getWithNewBitWidth(1);
14861490
unsigned Cost = 0;
14871491
// TODO: Ideally getCmpSelInstrCost would accept an icmp condition code.
1488-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1489-
CostKind);
1490-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1491-
CostKind);
1492+
Cost +=
1493+
thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1494+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
1495+
Cost +=
1496+
thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1497+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
14921498
// TODO: Should we add an OperandValueProperties::OP_Zero property?
14931499
if (IID == Intrinsic::abs)
14941500
Cost += thisT()->getArithmeticInstrCost(
@@ -1510,10 +1516,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15101516
IntrinsicCostAttributes Attrs(OverflowOp, OpTy, {RetTy, RetTy}, FMF,
15111517
ScalarizationCostPassed);
15121518
Cost += thisT()->getIntrinsicInstrCost(Attrs, CostKind);
1513-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1514-
CostKind);
1515-
Cost += 2 * thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy,
1516-
CondTy, CostKind);
1519+
Cost +=
1520+
thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, RetTy, CondTy,
1521+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
1522+
Cost += 2 * thisT()->getCmpSelInstrCost(
1523+
BinaryOperator::Select, RetTy, CondTy,
1524+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
15171525
return Cost;
15181526
}
15191527
case Intrinsic::uadd_sat:
@@ -1529,8 +1537,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15291537
IntrinsicCostAttributes Attrs(OverflowOp, OpTy, {RetTy, RetTy}, FMF,
15301538
ScalarizationCostPassed);
15311539
Cost += thisT()->getIntrinsicInstrCost(Attrs, CostKind);
1532-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1533-
CostKind);
1540+
Cost +=
1541+
thisT()->getCmpSelInstrCost(BinaryOperator::Select, RetTy, CondTy,
1542+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
15341543
return Cost;
15351544
}
15361545
case Intrinsic::smul_fix:
@@ -1575,10 +1584,12 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15751584
// Overflow -> (LHSSign != RHSSign) && (LHSSign != SumSign)
15761585
unsigned Cost = 0;
15771586
Cost += thisT()->getArithmeticInstrCost(Opcode, SumTy, CostKind);
1578-
Cost += 3 * thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, SumTy,
1579-
OverflowTy, CostKind);
1580-
Cost += 2 * thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, OverflowTy,
1581-
OverflowTy, CostKind);
1587+
Cost += 3 * thisT()->getCmpSelInstrCost(
1588+
BinaryOperator::ICmp, SumTy, OverflowTy,
1589+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
1590+
Cost += 2 * thisT()->getCmpSelInstrCost(
1591+
BinaryOperator::ICmp, OverflowTy, OverflowTy,
1592+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
15821593
Cost += thisT()->getArithmeticInstrCost(BinaryOperator::And, OverflowTy,
15831594
CostKind);
15841595
return Cost;
@@ -1593,8 +1604,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15931604

15941605
unsigned Cost = 0;
15951606
Cost += thisT()->getArithmeticInstrCost(Opcode, SumTy, CostKind);
1596-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, SumTy,
1597-
OverflowTy, CostKind);
1607+
Cost +=
1608+
thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, SumTy, OverflowTy,
1609+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
15981610
return Cost;
15991611
}
16001612
case Intrinsic::smul_with_overflow:
@@ -1623,8 +1635,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
16231635
CostKind, TTI::OK_AnyValue,
16241636
TTI::OK_UniformConstantValue);
16251637

1626-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, MulTy,
1627-
OverflowTy, CostKind);
1638+
Cost +=
1639+
thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, MulTy, OverflowTy,
1640+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
16281641
return Cost;
16291642
}
16301643
case Intrinsic::ctpop:
@@ -1866,9 +1879,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
18661879
(IsPairwise + 1) * thisT()->getShuffleCost(TTI::SK_ExtractSubvector,
18671880
Ty, NumVecElts, SubTy);
18681881
MinMaxCost +=
1869-
thisT()->getCmpSelInstrCost(CmpOpcode, SubTy, CondTy, CostKind) +
1882+
thisT()->getCmpSelInstrCost(CmpOpcode, SubTy, CondTy,
1883+
CmpInst::BAD_ICMP_PREDICATE, CostKind) +
18701884
thisT()->getCmpSelInstrCost(Instruction::Select, SubTy, CondTy,
1871-
CostKind);
1885+
CmpInst::BAD_ICMP_PREDICATE, CostKind);
18721886
Ty = SubTy;
18731887
++LongVectorCount;
18741888
}
@@ -1890,9 +1904,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
18901904
thisT()->getShuffleCost(TTI::SK_PermuteSingleSrc, Ty, 0, Ty);
18911905
MinMaxCost +=
18921906
NumReduxLevels *
1893-
(thisT()->getCmpSelInstrCost(CmpOpcode, Ty, CondTy, CostKind) +
1907+
(thisT()->getCmpSelInstrCost(CmpOpcode, Ty, CondTy,
1908+
CmpInst::BAD_ICMP_PREDICATE, CostKind) +
18941909
thisT()->getCmpSelInstrCost(Instruction::Select, Ty, CondTy,
1895-
CostKind));
1910+
CmpInst::BAD_ICMP_PREDICATE, CostKind));
18961911
// The last min/max should be in vector registers and we counted it above.
18971912
// So just need a single extractelement.
18981913
return ShuffleCost + MinMaxCost +

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,11 +807,13 @@ int TargetTransformInfo::getCFInstrCost(unsigned Opcode,
807807

808808
int TargetTransformInfo::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
809809
Type *CondTy,
810+
CmpInst::Predicate VecPred,
810811
TTI::TargetCostKind CostKind,
811812
const Instruction *I) const {
812813
assert((I == nullptr || I->getOpcode() == Opcode) &&
813814
"Opcode should reflect passed instruction.");
814-
int Cost = TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
815+
int Cost =
816+
TTIImpl->getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
815817
assert(Cost >= 0 && "TTI should not produce negative costs!");
816818
return Cost;
817819
}

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "AArch64ExpandImm.h"
109
#include "AArch64TargetTransformInfo.h"
10+
#include "AArch64ExpandImm.h"
1111
#include "MCTargetDesc/AArch64AddressingModes.h"
1212
#include "llvm/Analysis/LoopInfo.h"
1313
#include "llvm/Analysis/TargetTransformInfo.h"
@@ -16,9 +16,11 @@
1616
#include "llvm/CodeGen/TargetLowering.h"
1717
#include "llvm/IR/IntrinsicInst.h"
1818
#include "llvm/IR/IntrinsicsAArch64.h"
19+
#include "llvm/IR/PatternMatch.h"
1920
#include "llvm/Support/Debug.h"
2021
#include <algorithm>
2122
using namespace llvm;
23+
using namespace llvm::PatternMatch;
2224

2325
#define DEBUG_TYPE "aarch64tti"
2426

@@ -675,19 +677,40 @@ int AArch64TTIImpl::getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
675677
}
676678

677679
int AArch64TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
678-
Type *CondTy,
680+
Type *CondTy, CmpInst::Predicate VecPred,
679681
TTI::TargetCostKind CostKind,
680682
const Instruction *I) {
681683
// TODO: Handle other cost kinds.
682684
if (CostKind != TTI::TCK_RecipThroughput)
683-
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
685+
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
686+
I);
684687

685688
int ISD = TLI->InstructionOpcodeToISD(Opcode);
686689
// We don't lower some vector selects well that are wider than the register
687690
// width.
688691
if (ValTy->isVectorTy() && ISD == ISD::SELECT) {
689692
// We would need this many instructions to hide the scalarization happening.
690693
const int AmortizationCost = 20;
694+
695+
// If VecPred is not set, check if we can get a predicate from the context
696+
// instruction, if its type matches the requested ValTy.
697+
if (VecPred == CmpInst::BAD_ICMP_PREDICATE && I && I->getType() == ValTy) {
698+
CmpInst::Predicate CurrentPred;
699+
if (match(I, m_Select(m_Cmp(CurrentPred, m_Value(), m_Value()), m_Value(),
700+
m_Value())))
701+
VecPred = CurrentPred;
702+
}
703+
// Check if we have a compare/select chain that can be lowered using CMxx &
704+
// BFI pair.
705+
if (CmpInst::isIntPredicate(VecPred)) {
706+
static const auto ValidMinMaxTys = {MVT::v8i8, MVT::v16i8, MVT::v4i16,
707+
MVT::v8i16, MVT::v2i32, MVT::v4i32,
708+
MVT::v2i64};
709+
auto LT = TLI->getTypeLegalizationCost(DL, ValTy);
710+
if (any_of(ValidMinMaxTys, [&LT](MVT M) { return M == LT.second; }))
711+
return LT.first;
712+
}
713+
691714
static const TypeConversionCostTblEntry
692715
VectorSelectTbl[] = {
693716
{ ISD::SELECT, MVT::v16i1, MVT::v16i16, 16 },
@@ -707,7 +730,7 @@ int AArch64TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
707730
return Entry->Cost;
708731
}
709732
}
710-
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
733+
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
711734
}
712735

713736
AArch64TTIImpl::TTI::MemCmpExpansionOptions

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> {
141141
int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr);
142142

143143
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
144+
CmpInst::Predicate VecPred,
144145
TTI::TargetCostKind CostKind,
145146
const Instruction *I = nullptr);
146147

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ int ARMTTIImpl::getVectorInstrCost(unsigned Opcode, Type *ValTy,
810810
}
811811

812812
int ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
813+
CmpInst::Predicate VecPred,
813814
TTI::TargetCostKind CostKind,
814815
const Instruction *I) {
815816
int ISD = TLI->InstructionOpcodeToISD(Opcode);
@@ -839,7 +840,8 @@ int ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
839840
}
840841

841842
if (CostKind != TTI::TCK_RecipThroughput)
842-
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
843+
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
844+
I);
843845

844846
// On NEON a vector select gets lowered to vbsl.
845847
if (ST->hasNEON() && ValTy->isVectorTy() && ISD == ISD::SELECT) {
@@ -866,8 +868,8 @@ int ARMTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
866868
int BaseCost = ST->hasMVEIntegerOps() && ValTy->isVectorTy()
867869
? ST->getMVEVectorCostFactor()
868870
: 1;
869-
return BaseCost * BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind,
870-
I);
871+
return BaseCost *
872+
BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
871873
}
872874

873875
int ARMTTIImpl::getAddressComputationCost(Type *Ty, ScalarEvolution *SE,

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
213213
const Instruction *I = nullptr);
214214

215215
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
216+
CmpInst::Predicate VecPred,
216217
TTI::TargetCostKind CostKind,
217218
const Instruction *I = nullptr);
218219

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,16 @@ unsigned HexagonTTIImpl::getInterleavedMemoryOpCost(
242242
}
243243

244244
unsigned HexagonTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
245-
Type *CondTy, TTI::TargetCostKind CostKind, const Instruction *I) {
245+
Type *CondTy,
246+
CmpInst::Predicate VecPred,
247+
TTI::TargetCostKind CostKind,
248+
const Instruction *I) {
246249
if (ValTy->isVectorTy() && CostKind == TTI::TCK_RecipThroughput) {
247250
std::pair<int, MVT> LT = TLI.getTypeLegalizationCost(DL, ValTy);
248251
if (Opcode == Instruction::FCmp)
249252
return LT.first + FloatFactor * getTypeNumElements(ValTy);
250253
}
251-
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, CostKind, I);
254+
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind, I);
252255
}
253256

254257
unsigned HexagonTTIImpl::getArithmeticInstrCost(

llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class HexagonTTIImpl : public BasicTTIImplBase<HexagonTTIImpl> {
134134
TTI::TargetCostKind CostKind = TTI::TCK_SizeAndLatency,
135135
bool UseMaskForCond = false, bool UseMaskForGaps = false);
136136
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy,
137+
138+
CmpInst::Predicate VecPred,
137139
TTI::TargetCostKind CostKind,
138140
const Instruction *I = nullptr);
139141
unsigned getArithmeticInstrCost(

0 commit comments

Comments
 (0)