30#define DEBUG_TYPE "systemztti"
39 bool UsedAsMemCpySource =
false;
47 if (Memcpy->getOperand(1) == V && !Memcpy->isVolatile()) {
48 UsedAsMemCpySource =
true;
54 return UsedAsMemCpySource;
63 if (
User->getParent()->getParent() ==
F) {
65 if (
SI->getPointerOperand() == Ptr && !
SI->isVolatile())
68 if (LI->getPointerOperand() == Ptr && !LI->isVolatile())
71 if (
GEP->getPointerOperand() == Ptr)
87 for (
const Argument &Arg : Callee->args()) {
88 bool OtherUse =
false;
105 if (!
SI->isVolatile())
109 if (!LI->isVolatile())
114 unsigned NumStores = 0, NumLoads = 0;
116 Ptr2NumUses[GV] += NumLoads + NumStores;
121 for (
auto [Ptr, NumCalleeUses] : Ptr2NumUses)
122 if (NumCalleeUses > 10) {
123 unsigned CallerStores = 0, CallerLoads = 0;
125 if (CallerStores + CallerLoads > 10) {
132 unsigned NumStores = 0;
133 unsigned NumLoads = 0;
134 for (
unsigned OpIdx = 0; OpIdx != Callee->arg_size(); ++OpIdx) {
136 Argument *CalleeArg = Callee->getArg(OpIdx);
141 Bonus += NumLoads * 50;
143 Bonus += NumStores * 50;
144 Bonus = std::min(Bonus,
unsigned(1000));
147 dbgs() <<
"++ SZTTI Adding inlining bonus: " << Bonus <<
"\n";);
154 assert(Ty->isIntegerTy());
156 unsigned BitSize = Ty->getPrimitiveSizeInBits();
162 if ((!ST->hasVector() && BitSize > 64) || BitSize > 128)
168 if (
Imm.getBitWidth() <= 64) {
176 if ((
Imm.getZExtValue() & 0xffffffff) == 0)
190 assert(Ty->isIntegerTy());
192 unsigned BitSize = Ty->getPrimitiveSizeInBits();
204 case Instruction::GetElementPtr:
211 case Instruction::Store:
212 if (Idx == 0 &&
Imm.getBitWidth() <= 64) {
221 case Instruction::ICmp:
222 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
231 case Instruction::Add:
232 case Instruction::Sub:
233 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
242 case Instruction::Mul:
243 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
249 case Instruction::Or:
250 case Instruction::Xor:
251 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
256 if ((
Imm.getZExtValue() & 0xffffffff) == 0)
260 case Instruction::And:
261 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
269 if ((
Imm.getZExtValue() & 0xffffffff) == 0xffffffff)
274 if (
TII->isRxSBGMask(
Imm.getZExtValue(), BitSize, Start, End))
278 case Instruction::Shl:
279 case Instruction::LShr:
280 case Instruction::AShr:
285 case Instruction::UDiv:
286 case Instruction::SDiv:
287 case Instruction::URem:
288 case Instruction::SRem:
289 case Instruction::Trunc:
290 case Instruction::ZExt:
291 case Instruction::SExt:
292 case Instruction::IntToPtr:
293 case Instruction::PtrToInt:
294 case Instruction::BitCast:
295 case Instruction::PHI:
296 case Instruction::Call:
297 case Instruction::Select:
298 case Instruction::Ret:
299 case Instruction::Load:
310 assert(Ty->isIntegerTy());
312 unsigned BitSize = Ty->getPrimitiveSizeInBits();
324 case Intrinsic::sadd_with_overflow:
325 case Intrinsic::uadd_with_overflow:
326 case Intrinsic::ssub_with_overflow:
327 case Intrinsic::usub_with_overflow:
329 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
336 case Intrinsic::smul_with_overflow:
337 case Intrinsic::umul_with_overflow:
339 if (Idx == 1 &&
Imm.getBitWidth() <= 64) {
344 case Intrinsic::experimental_stackmap:
345 if ((Idx < 2) || (
Imm.getBitWidth() <= 64 &&
isInt<64>(
Imm.getSExtValue())))
348 case Intrinsic::experimental_patchpoint_void:
349 case Intrinsic::experimental_patchpoint:
350 if ((Idx < 4) || (
Imm.getBitWidth() <= 64 &&
isInt<64>(
Imm.getSExtValue())))
360 if (ST->hasPopulationCount() && TyWidth <= 64)
370 bool HasCall =
false;
372 for (
auto &BB : L->blocks())
373 for (
auto &
I : *BB) {
378 if (
F->getIntrinsicID() == Intrinsic::memcpy ||
379 F->getIntrinsicID() == Intrinsic::memset)
386 Type *MemAccessTy =
I.getOperand(0)->getType();
395 unsigned const NumStoresVal = NumStores.
getValue();
396 unsigned const Max = (NumStoresVal ? (12 / NumStoresVal) : UINT_MAX);
440 bool Vector = (ClassID == 1);
465 unsigned NumStridedMemAccesses,
466 unsigned NumPrefetches,
467 bool HasCall)
const {
469 if (NumPrefetches > 16)
474 if (NumStridedMemAccesses > 32 && !HasCall &&
475 (NumMemAccesses - NumStridedMemAccesses) * 32 <= NumStridedMemAccesses)
478 return ST->hasMiscellaneousExtensions3() ? 8192 : 2048;
483 bool HasUnorderedReductions)
const {
488 EVT VT = TLI->getValueType(
DL, DataType);
507 if (Insert && Ty->isIntOrIntVectorTy(64)) {
511 "Type does not match the number of values.");
513 for (
unsigned Idx = 0; Idx < NumElts; ++Idx) {
533 (Ty->isPtrOrPtrVectorTy() ? 64U : Ty->getScalarSizeInBits());
534 assert(
Size > 0 &&
"Element must have non-zero size.");
544 assert(WideBits > 0 &&
"Could not compute size of vector");
545 return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U));
550 if (!BI || !BI->hasOneUse())
553 unsigned Opcode = BI->getOpcode();
554 unsigned BitWidth = Ty->getScalarSizeInBits();
557 case Instruction::And:
558 case Instruction::Or:
559 case Instruction::Xor: {
570 if (Opcode == Instruction::And) {
571 if (
BitWidth == 16 && (Val & 0xff00ULL) != 0xff00ULL)
573 if (
BitWidth == 32 && (Val & 0xffffff00ULL) != 0xffffff00ULL)
576 (Val & 0xffffffffffffff00ULL) != 0xffffffffffffff00ULL)
579 if (CI->getValue().getActiveBits() > 8) {
585 case Instruction::Add:
586 case Instruction::Sub:
594 Value *Op0 = BI->getOperand(0), *Op1 = BI->getOperand(1);
607 return LI &&
SI && !LI->isVolatile() && !
SI->isVolatile() &&
608 LI->hasOneUse() && LI->getPointerOperand() ==
SI->getPointerOperand();
619 Op2Info, Args, CtxI);
620 if (CtxI && Ty && !Ty->isVectorTy() &&
isFoldableRMW(CtxI, Ty))
628 unsigned ScalarBits = Ty->getScalarSizeInBits();
634 const unsigned DivInstrCost = 20;
635 const unsigned DivMulSeqCost = 10;
636 const unsigned SDivPow2Cost = 4;
639 Opcode == Instruction::SDiv || Opcode == Instruction::SRem;
640 bool UnsignedDivRem =
641 Opcode == Instruction::UDiv || Opcode == Instruction::URem;
644 bool DivRemConst =
false;
645 bool DivRemConstPow2 =
false;
646 if ((SignedDivRem || UnsignedDivRem) && Args.size() == 2) {
649 (
C->getType()->isVectorTy()
654 DivRemConstPow2 =
true;
660 if (!Ty->isVectorTy()) {
664 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub ||
665 Opcode == Instruction::FMul || Opcode == Instruction::FDiv)
669 if (Opcode == Instruction::FRem)
673 if (Args.size() == 2) {
674 if (Opcode == Instruction::Xor) {
675 for (
const Value *
A : Args) {
677 if (
I->hasOneUse() &&
678 (
I->getOpcode() == Instruction::Or ||
679 I->getOpcode() == Instruction::And ||
680 I->getOpcode() == Instruction::Xor))
681 if ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
683 (
I->getOpcode() == Instruction::Or || ST->hasVectorEnhancements1())))
687 else if (Opcode == Instruction::And || Opcode == Instruction::Or) {
688 for (
const Value *
A : Args) {
690 if ((
I->hasOneUse() &&
I->getOpcode() == Instruction::Xor) &&
691 ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
693 (Opcode == Instruction::And || ST->hasVectorEnhancements1()))))
700 if (Opcode == Instruction::Or)
703 if (Opcode == Instruction::Xor && ScalarBits == 1) {
704 if (ST->hasLoadStoreOnCond2())
710 return (SignedDivRem ? SDivPow2Cost : 1);
712 return DivMulSeqCost;
713 if (SignedDivRem || UnsignedDivRem)
716 else if (ST->hasVector()) {
718 unsigned VF = VTy->getNumElements();
723 if (Opcode == Instruction::Shl || Opcode == Instruction::LShr ||
724 Opcode == Instruction::AShr) {
729 return (NumVectors * (SignedDivRem ? SDivPow2Cost : 1));
732 return VF * DivMulSeqCost +
735 if (SignedDivRem || UnsignedDivRem) {
736 if (ST->hasVectorEnhancements3() && ScalarBits >= 32)
737 return NumVectors * DivInstrCost;
750 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub ||
751 Opcode == Instruction::FMul || Opcode == Instruction::FDiv) {
752 switch (ScalarBits) {
755 if (ST->hasVectorEnhancements1())
780 if (Opcode == Instruction::FRem) {
783 (VF * LIBCALL_COST) +
786 if (VF == 2 && ScalarBits == 32)
803 if (ST->hasVector()) {
811 if (SrcTy->getScalarType()->isFP128Ty())
819 return (Index == 0 ? 0 : NumVectors);
826 return NumVectors - 1;
854 "Packing must reduce size of vector type.");
857 "Packing should not change number of elements.");
873 for (
unsigned P = 0;
P < Log2Diff; ++
P) {
882 if (VF == 8 && SrcTy->getScalarSizeInBits() == 64 &&
894 "Should only be called with vector types.");
896 unsigned PackCost = 0;
900 if (SrcScalarBits > DstScalarBits)
903 else if (SrcScalarBits < DstScalarBits) {
906 PackCost = Log2Diff * DstNumParts;
908 PackCost += DstNumParts - 1;
919 OpTy = CI->getOperand(0)->getType();
921 if (LogicI->getNumOperands() == 2)
924 OpTy = CI0->getOperand(0)->getType();
926 if (
OpTy !=
nullptr) {
928 assert (!
OpTy->isVectorTy() &&
"Expected scalar type");
946 unsigned VF = DstVTy->getNumElements();
951 if (CmpOpTy !=
nullptr)
953 if (Opcode == Instruction::ZExt || Opcode == Instruction::UIToFP)
967 return BaseCost == 0 ? BaseCost : 1;
970 unsigned DstScalarBits = Dst->getScalarSizeInBits();
971 unsigned SrcScalarBits = Src->getScalarSizeInBits();
973 if (!Src->isVectorTy()) {
974 if (Dst->isVectorTy())
977 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP) {
978 if (Src->isIntegerTy(128))
980 if (SrcScalarBits >= 32 ||
983 return SrcScalarBits > 1 ? 2 : 5 ;
986 if ((Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) &&
987 Dst->isIntegerTy(128))
990 if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt)) {
991 if (Src->isIntegerTy(1)) {
992 if (DstScalarBits == 128) {
993 if (Opcode == Instruction::SExt && ST->hasVectorEnhancements3())
998 if (ST->hasLoadStoreOnCond2())
1004 if (Opcode == Instruction::SExt)
1005 Cost = (DstScalarBits < 64 ? 3 : 4);
1006 if (Opcode == Instruction::ZExt)
1014 else if (isInt128InVR(Dst)) {
1017 if (Opcode == Instruction::ZExt &&
I !=
nullptr)
1019 if (Ld->hasOneUse())
1025 if (Opcode == Instruction::Trunc && isInt128InVR(Src) &&
I !=
nullptr) {
1027 if (Ld->hasOneUse())
1029 bool OnlyTruncatingStores =
true;
1030 for (
const User *U :
I->users())
1032 OnlyTruncatingStores =
false;
1035 if (OnlyTruncatingStores)
1040 else if (ST->hasVector()) {
1048 unsigned VF = SrcVecTy->getNumElements();
1052 if (Opcode == Instruction::Trunc) {
1053 if (Src->getScalarSizeInBits() == Dst->getScalarSizeInBits())
1058 if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt) {
1059 if (SrcScalarBits >= 8) {
1061 if (Opcode == Instruction::ZExt)
1062 return NumDstVectors;
1069 unsigned NumSrcVectorOps =
1070 (NumUnpacks > 1 ? (NumDstVectors - NumSrcVectors)
1071 : (NumDstVectors / 2));
1073 return (NumUnpacks * NumDstVectors) + NumSrcVectorOps;
1075 else if (SrcScalarBits == 1)
1079 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP ||
1080 Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) {
1085 if (DstScalarBits == 64 || ST->hasVectorEnhancements2()) {
1086 if (SrcScalarBits == DstScalarBits)
1087 return NumDstVectors;
1089 if (SrcScalarBits == 1)
1097 Opcode, Dst->getScalarType(), Src->getScalarType(), CCH,
CostKind);
1099 bool NeedsInserts =
true, NeedsExtracts =
true;
1101 if (DstScalarBits == 128 &&
1102 (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP))
1103 NeedsInserts =
false;
1104 if (SrcScalarBits == 128 &&
1105 (Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI))
1106 NeedsExtracts =
false;
1114 if (VF == 2 && SrcScalarBits == 32 && DstScalarBits == 32)
1120 if (Opcode == Instruction::FPTrunc) {
1121 if (SrcScalarBits == 128)
1126 return VF / 2 + std::max(1U, VF / 4 );
1129 if (Opcode == Instruction::FPExt) {
1130 if (SrcScalarBits == 32 && DstScalarBits == 64) {
1148 unsigned ExtCost = 0;
1176 case Instruction::ICmp: {
1180 if (
I !=
nullptr && (ScalarBits == 32 || ScalarBits == 64))
1183 if (!Ld->hasOneUse() && Ld->getParent() ==
I->getParent() &&
1192 case Instruction::Select:
1200 if (CI->getOperand(0)->getType()->isIntegerTy(128))
1201 return ST->hasVectorEnhancements3() ? 1 : 4;
1204 return !isInt128InVR(ValTy) ? 1 : 4;
1207 else if (ST->hasVector()) {
1211 if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
1212 unsigned PredicateExtraCost = 0;
1221 PredicateExtraCost = 1;
1227 PredicateExtraCost = 2;
1236 unsigned CmpCostPerVector = (ValTy->
getScalarType()->isFloatTy() ? 10 : 1);
1239 unsigned Cost = (NumVecs_cmp * (CmpCostPerVector + PredicateExtraCost));
1243 assert (Opcode == Instruction::Select);
1247 unsigned PackCost = 0;
1249 if (CmpOpTy !=
nullptr)
1264 if (Opcode == Instruction::InsertElement) {
1273 return ((Index % 2 == 0) ? 1 : 0);
1276 if (Opcode == Instruction::ExtractElement) {
1292 if (!Ld->hasOneUse())
1297 unsigned TruncBits = 0;
1298 unsigned SExtBits = 0;
1299 unsigned ZExtBits = 0;
1303 TruncBits = UserBits;
1305 SExtBits = UserBits;
1307 ZExtBits = UserBits;
1309 if (TruncBits || SExtBits || ZExtBits) {
1310 FoldedValue = UserI;
1314 if ((UserI->
getOpcode() == Instruction::Sub ||
1315 UserI->
getOpcode() == Instruction::SDiv ||
1316 UserI->
getOpcode() == Instruction::UDiv) &&
1321 unsigned LoadOrTruncBits =
1322 ((SExtBits || ZExtBits) ? 0 : (TruncBits ? TruncBits : LoadedBits));
1324 case Instruction::Add:
1325 case Instruction::Sub:
1326 case Instruction::ICmp:
1327 if (LoadedBits == 32 && ZExtBits == 64)
1330 case Instruction::Mul:
1331 if (UserI->
getOpcode() != Instruction::ICmp) {
1332 if (LoadedBits == 16 &&
1334 (SExtBits == 64 && ST->hasMiscellaneousExtensions2())))
1336 if (LoadOrTruncBits == 16)
1340 case Instruction::SDiv:
1341 if (LoadedBits == 32 && SExtBits == 64)
1344 case Instruction::UDiv:
1345 case Instruction::And:
1346 case Instruction::Or:
1347 case Instruction::Xor:
1359 if (UserI->
getOpcode() == Instruction::ICmp)
1361 if (CI->getValue().isIntN(16))
1363 return (LoadOrTruncBits == 32 || LoadOrTruncBits == 64);
1372 if (
auto *
F = CI->getCalledFunction())
1373 if (
F->getIntrinsicID() == Intrinsic::bswap)
1384 assert(!Src->isVoidTy() &&
"Invalid type");
1395 if (
I && Opcode == Instruction::Store && !Src->isVectorTy()) {
1400 if (!Src->isVectorTy() && Opcode == Instruction::Load &&
I !=
nullptr) {
1409 for (
unsigned i = 0; i < 2; ++i) {
1429 if (TLI->getValueType(
DL, Src,
true) == MVT::Other)
1434 if (Src->isFP128Ty() && !ST->hasVectorEnhancements1())
1441 if (((!Src->isVectorTy() &&
NumOps == 1) || ST->hasVectorEnhancements2()) &&
1443 if (Opcode == Instruction::Load &&
I->hasOneUse()) {
1451 const Value *StoredVal =
SI->getValueOperand();
1468 bool UseMaskForCond,
bool UseMaskForGaps)
const {
1469 if (UseMaskForCond || UseMaskForGaps)
1472 UseMaskForCond, UseMaskForGaps);
1474 "Expect a vector type for interleaved memory op");
1477 assert(Factor > 1 && NumElts % Factor == 0 &&
"Invalid interleave factor");
1478 unsigned VF = NumElts / Factor;
1481 unsigned NumPermutes = 0;
1483 if (Opcode == Instruction::Load) {
1487 BitVector UsedInsts(NumVectorMemOps,
false);
1488 std::vector<BitVector> ValueVecs(Factor,
BitVector(NumVectorMemOps,
false));
1489 for (
unsigned Index : Indices)
1490 for (
unsigned Elt = 0; Elt < VF; ++Elt) {
1491 unsigned Vec = (Index + Elt * Factor) / NumEltsPerVecReg;
1493 ValueVecs[Index].set(Vec);
1495 NumVectorMemOps = UsedInsts.
count();
1497 for (
unsigned Index : Indices) {
1501 unsigned NumSrcVecs = ValueVecs[Index].count();
1503 assert (NumSrcVecs >= NumDstVecs &&
"Expected at least as many sources");
1504 NumPermutes += std::max(1U, NumSrcVecs - NumDstVecs);
1510 unsigned NumSrcVecs = std::min(NumEltsPerVecReg, Factor);
1511 unsigned NumDstVecs = NumVectorMemOps;
1512 NumPermutes += (NumDstVecs * NumSrcVecs) - NumDstVecs;
1516 return NumVectorMemOps + NumPermutes;
1524 Cost += (ScalarBits < 32) ? 3 : 2;
1529 unsigned ScalarBits) {
1536 Cost += 2 *
Log2_32_Ceil(std::min(NumElems, NumEltsPerVecReg));
1541 return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
1542 Opcode == Instruction::Add || Opcode == Instruction::Mul;
1547 std::optional<FastMathFlags> FMF,
1549 unsigned ScalarBits = Ty->getScalarSizeInBits();
1558 if (Opcode == Instruction::Add)
1564 if ((Opcode == Instruction::FAdd) || (Opcode == Instruction::FMul))
1577 if (ST->hasVectorEnhancements1()) {
1580 unsigned ScalarBits = Ty->getScalarSizeInBits();
1583 Cost += NumVectors - 1;
1596 if (RetTy->
isVectorTy() && ID == Intrinsic::bswap)
1614 if (!ST->hasVector())
1618 switch (
II->getIntrinsicID()) {
1622 case Intrinsic::vector_reduce_add:
1627 return VType->getScalarSizeInBits() >= 64 ||
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Expand Atomic instructions
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static unsigned InstrCount
const HexagonInstrInfo * TII
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
static const Function * getCalledFunction(const Value *V)
uint64_t IntrinsicInst * II
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
bool isNegatedPowerOf2() const
Check if this APInt's negated value is a power of two greater than zero.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
This class represents an incoming formal argument to a Function.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
unsigned getNumberOfParts(Type *Tp) const override
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *SrcTy, int &Index, VectorType *&SubTy) const
InstructionCost getScalarizationOverhead(VectorType *InTy, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
size_type count() const
Returns the number of bits which are set.
BitVector & set()
Set all bits in the bitvector.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Value * getArgOperand(unsigned i) const
This class is the base class for the comparison instructions.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_SLE
signed less or equal
@ ICMP_UGE
unsigned greater or equal
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
This is the shared class of boolean and integer constants.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
constexpr bool isVector() const
One or more elements.
Convenience struct for specifying and reasoning about fast-math flags.
Class to represent fixed width SIMD vectors.
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
This instruction compares its operands according to the predicate given to the constructor.
CostType getValue() const
This function is intended to be used as sparingly as possible, since the class provides the full rang...
user_iterator user_begin()
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
const SmallVectorImpl< Type * > & getArgTypes() const
Type * getReturnType() const
Intrinsic::ID getID() const
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
Represents a single loop in the control flow graph.
This class wraps the llvm.memcpy intrinsic.
The main scalar evolution driver.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
Estimate the overhead of scalarizing an instruction.
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue) const
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2) const override
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind) const override
Try to calculate op costs for min/max reduction operations.
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
unsigned getNumberOfRegisters(unsigned ClassID) const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP) const override
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const override
Get intrinsic cost based on arguments.
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const override
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy) const
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, const Instruction *I) const
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const override
bool shouldExpandReduction(const IntrinsicInst *II) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth) const override
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false) const override
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr) const override
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const override
bool hasDivRemOp(Type *DataType, bool IsSigned) const override
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy) const
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE) const override
unsigned adjustInliningThreshold(const CallBase *CB) const override
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr) const override
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const override
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const override
unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const override
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const override
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
iterator_range< user_iterator > users()
Base class of all SIMD vector types.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const unsigned VectorBits
This is an optimization pass for GlobalISel generic memory operations.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto dyn_cast_or_null(const Y &Val)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
DWARFExpression::Operation Op
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isScalarInteger() const
Return true if this is an integer, but not a vector.