29#define DEBUG_TYPE "systemztti"
38 bool UsedAsMemCpySource =
false;
39 for (
const User *U : V->users())
41 if (isa<BitCastInst>(
User) || isa<GetElementPtrInst>(
User)) {
46 if (Memcpy->getOperand(1) == V && !Memcpy->isVolatile()) {
47 UsedAsMemCpySource =
true;
53 return UsedAsMemCpySource;
58 if (!isa<PointerType>(
Ptr->getType()))
60 for (
const User *U :
Ptr->users())
62 if (
User->getParent()->getParent() ==
F) {
63 if (
const auto *SI = dyn_cast<StoreInst>(
User)) {
64 if (SI->getPointerOperand() ==
Ptr && !SI->isVolatile())
66 }
else if (
const auto *LI = dyn_cast<LoadInst>(
User)) {
67 if (LI->getPointerOperand() ==
Ptr && !LI->isVolatile())
69 }
else if (
const auto *
GEP = dyn_cast<GetElementPtrInst>(
User)) {
70 if (
GEP->getPointerOperand() ==
Ptr)
83 const Module *M = Caller->getParent();
87 for (
const Argument &Arg : Callee->args()) {
88 bool OtherUse =
false;
96 std::set<const GlobalVariable *> CalleeGlobals;
97 std::set<const GlobalVariable *> CallerGlobals;
101 if (
User->getParent()->getParent() == Callee)
102 CalleeGlobals.insert(&
Global);
103 if (
User->getParent()->getParent() == Caller)
104 CallerGlobals.insert(&
Global);
106 for (
auto *GV : CalleeGlobals)
107 if (CallerGlobals.count(GV)) {
108 unsigned CalleeStores = 0, CalleeLoads = 0;
109 unsigned CallerStores = 0, CallerLoads = 0;
112 if ((CalleeStores + CalleeLoads) > 10 &&
113 (CallerStores + CallerLoads) > 10) {
120 unsigned NumStores = 0;
121 unsigned NumLoads = 0;
122 for (
unsigned OpIdx = 0; OpIdx != Callee->arg_size(); ++OpIdx) {
124 Argument *CalleeArg = Callee->getArg(OpIdx);
125 if (isa<AllocaInst>(CallerArg))
129 Bonus += NumLoads * 50;
131 Bonus += NumStores * 50;
132 Bonus = std::min(Bonus,
unsigned(1000));
135 dbgs() <<
"++ SZTTI Adding inlining bonus: " << Bonus <<
"\n";);
149 if ((!ST->hasVector() && BitSize > 64) || BitSize > 128)
155 if (Imm.getBitWidth() <= 64) {
157 if (isInt<32>(Imm.getSExtValue()))
160 if (isUInt<32>(Imm.getZExtValue()))
163 if ((Imm.getZExtValue() & 0xffffffff) == 0)
191 case Instruction::GetElementPtr:
198 case Instruction::Store:
199 if (
Idx == 0 && Imm.getBitWidth() <= 64) {
204 if (isInt<16>(Imm.getSExtValue()))
208 case Instruction::ICmp:
209 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
211 if (isInt<32>(Imm.getSExtValue()))
214 if (isUInt<32>(Imm.getZExtValue()))
218 case Instruction::Add:
219 case Instruction::Sub:
220 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
222 if (isUInt<32>(Imm.getZExtValue()))
225 if (isUInt<32>(-Imm.getSExtValue()))
229 case Instruction::Mul:
230 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
232 if (isInt<32>(Imm.getSExtValue()))
236 case Instruction::Or:
237 case Instruction::Xor:
238 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
240 if (isUInt<32>(Imm.getZExtValue()))
243 if ((Imm.getZExtValue() & 0xffffffff) == 0)
247 case Instruction::And:
248 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
253 if (isUInt<32>(~Imm.getZExtValue()))
256 if ((Imm.getZExtValue() & 0xffffffff) == 0xffffffff)
261 if (
TII->isRxSBGMask(Imm.getZExtValue(), BitSize, Start,
End))
265 case Instruction::Shl:
266 case Instruction::LShr:
267 case Instruction::AShr:
272 case Instruction::UDiv:
273 case Instruction::SDiv:
274 case Instruction::URem:
275 case Instruction::SRem:
276 case Instruction::Trunc:
277 case Instruction::ZExt:
278 case Instruction::SExt:
279 case Instruction::IntToPtr:
280 case Instruction::PtrToInt:
281 case Instruction::BitCast:
282 case Instruction::PHI:
283 case Instruction::Call:
284 case Instruction::Select:
285 case Instruction::Ret:
286 case Instruction::Load:
311 case Intrinsic::sadd_with_overflow:
312 case Intrinsic::uadd_with_overflow:
313 case Intrinsic::ssub_with_overflow:
314 case Intrinsic::usub_with_overflow:
316 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
317 if (isUInt<32>(Imm.getZExtValue()))
319 if (isUInt<32>(-Imm.getSExtValue()))
323 case Intrinsic::smul_with_overflow:
324 case Intrinsic::umul_with_overflow:
326 if (
Idx == 1 && Imm.getBitWidth() <= 64) {
327 if (isInt<32>(Imm.getSExtValue()))
331 case Intrinsic::experimental_stackmap:
332 if ((
Idx < 2) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
335 case Intrinsic::experimental_patchpoint_void:
336 case Intrinsic::experimental_patchpoint:
337 if ((
Idx < 4) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
347 if (ST->hasPopulationCount() && TyWidth <= 64)
357 bool HasCall =
false;
359 for (
auto &BB : L->blocks())
360 for (
auto &
I : *BB) {
361 if (isa<CallInst>(&
I) || isa<InvokeInst>(&
I)) {
365 if (
F->getIntrinsicID() == Intrinsic::memcpy ||
366 F->getIntrinsicID() == Intrinsic::memset)
372 if (isa<StoreInst>(&
I)) {
373 Type *MemAccessTy =
I.getOperand(0)->getType();
382 unsigned const NumStoresVal = *NumStores.
getValue();
383 unsigned const Max = (NumStoresVal ? (12 / NumStoresVal) : UINT_MAX);
426 bool Vector = (ClassID == 1);
451 unsigned NumStridedMemAccesses,
452 unsigned NumPrefetches,
453 bool HasCall)
const {
455 if (NumPrefetches > 16)
460 if (NumStridedMemAccesses > 32 && !HasCall &&
461 (NumMemAccesses - NumStridedMemAccesses) * 32 <= NumStridedMemAccesses)
464 return ST->hasMiscellaneousExtensions3() ? 8192 : 2048;
473 if (isa<LoadInst>(
Op) &&
Op->hasOneUse()) {
474 const Instruction *UserI = cast<Instruction>(*
Op->user_begin());
475 return !isa<StoreInst>(UserI);
483 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
490 "Type does not match the number of values.");
492 for (
unsigned Idx = 0;
Idx < NumElts; ++
Idx) {
513 assert(
Size > 0 &&
"Element must have non-zero size.");
521 auto *VTy = cast<FixedVectorType>(Ty);
523 assert(WideBits > 0 &&
"Could not compute size of vector");
524 return ((WideBits % 128U) ? ((WideBits / 128U) + 1) : (WideBits / 128U));
536 Op2Info, Args, CxtI);
550 const unsigned DivInstrCost = 20;
551 const unsigned DivMulSeqCost = 10;
552 const unsigned SDivPow2Cost = 4;
555 Opcode == Instruction::SDiv || Opcode == Instruction::SRem;
556 bool UnsignedDivRem =
557 Opcode == Instruction::UDiv || Opcode == Instruction::URem;
560 bool DivRemConst =
false;
561 bool DivRemConstPow2 =
false;
562 if ((SignedDivRem || UnsignedDivRem) && Args.size() == 2) {
563 if (
const Constant *
C = dyn_cast<Constant>(Args[1])) {
565 (
C->getType()->isVectorTy()
566 ? dyn_cast_or_null<const ConstantInt>(
C->getSplatValue())
567 : dyn_cast<const ConstantInt>(
C));
570 DivRemConstPow2 =
true;
580 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub ||
581 Opcode == Instruction::FMul || Opcode == Instruction::FDiv)
585 if (Opcode == Instruction::FRem)
589 if (Args.size() == 2) {
590 if (Opcode == Instruction::Xor) {
591 for (
const Value *
A : Args) {
593 if (
I->hasOneUse() &&
594 (
I->getOpcode() == Instruction::Or ||
595 I->getOpcode() == Instruction::And ||
596 I->getOpcode() == Instruction::Xor))
597 if ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
599 (
I->getOpcode() == Instruction::Or || ST->hasVectorEnhancements1())))
603 else if (Opcode == Instruction::And || Opcode == Instruction::Or) {
604 for (
const Value *
A : Args) {
606 if ((
I->hasOneUse() &&
I->getOpcode() == Instruction::Xor) &&
607 ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
609 (Opcode == Instruction::And || ST->hasVectorEnhancements1()))))
616 if (Opcode == Instruction::Or)
619 if (Opcode == Instruction::Xor && ScalarBits == 1) {
620 if (ST->hasLoadStoreOnCond2())
626 return (SignedDivRem ? SDivPow2Cost : 1);
628 return DivMulSeqCost;
629 if (SignedDivRem || UnsignedDivRem)
632 else if (ST->hasVector()) {
633 auto *VTy = cast<FixedVectorType>(Ty);
634 unsigned VF = VTy->getNumElements();
639 if (Opcode == Instruction::Shl || Opcode == Instruction::LShr ||
640 Opcode == Instruction::AShr) {
645 return (NumVectors * (SignedDivRem ? SDivPow2Cost : 1));
648 return VF * DivMulSeqCost +
651 if (SignedDivRem || UnsignedDivRem) {
652 if (ST->hasVectorEnhancements3() && ScalarBits >= 32)
653 return NumVectors * DivInstrCost;
666 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub ||
667 Opcode == Instruction::FMul || Opcode == Instruction::FDiv) {
668 switch (ScalarBits) {
671 if (ST->hasVectorEnhancements1())
696 if (Opcode == Instruction::FRem) {
699 (VF * LIBCALL_COST) +
702 if (VF == 2 && ScalarBits == 32)
718 if (ST->hasVector()) {
734 return (Index == 0 ? 0 : NumVectors);
741 return NumVectors - 1;
770 "Packing must reduce size of vector type.");
773 "Packing should not change number of elements.");
788 unsigned VF = cast<FixedVectorType>(SrcTy)->getNumElements();
789 for (
unsigned P = 0;
P < Log2Diff; ++
P) {
810 "Should only be called with vector types.");
812 unsigned PackCost = 0;
816 if (SrcScalarBits > DstScalarBits)
819 else if (SrcScalarBits < DstScalarBits) {
822 PackCost = Log2Diff * DstNumParts;
824 PackCost += DstNumParts - 1;
833 Type *OpTy =
nullptr;
834 if (
CmpInst *CI = dyn_cast<CmpInst>(
I->getOperand(0)))
835 OpTy = CI->getOperand(0)->getType();
836 else if (
Instruction *LogicI = dyn_cast<Instruction>(
I->getOperand(0)))
837 if (LogicI->getNumOperands() == 2)
838 if (
CmpInst *CI0 = dyn_cast<CmpInst>(LogicI->getOperand(0)))
839 if (isa<CmpInst>(LogicI->getOperand(1)))
840 OpTy = CI0->getOperand(0)->getType();
842 if (OpTy !=
nullptr) {
861 auto *DstVTy = cast<FixedVectorType>(Dst);
862 unsigned VF = DstVTy->getNumElements();
867 if (CmpOpTy !=
nullptr)
869 if (Opcode == Instruction::ZExt || Opcode == Instruction::UIToFP)
883 return BaseCost == 0 ? BaseCost : 1;
886 unsigned DstScalarBits = Dst->getScalarSizeInBits();
887 unsigned SrcScalarBits = Src->getScalarSizeInBits();
889 if (!Src->isVectorTy()) {
890 assert (!Dst->isVectorTy());
892 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP) {
893 if (Src->isIntegerTy(128))
895 if (SrcScalarBits >= 32 ||
896 (
I !=
nullptr && isa<LoadInst>(
I->getOperand(0))))
898 return SrcScalarBits > 1 ? 2 : 5 ;
901 if ((Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) &&
902 Dst->isIntegerTy(128))
905 if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt)) {
906 if (Src->isIntegerTy(1)) {
907 if (DstScalarBits == 128) {
908 if (Opcode == Instruction::SExt && ST->hasVectorEnhancements3())
913 if (ST->hasLoadStoreOnCond2())
919 if (Opcode == Instruction::SExt)
920 Cost = (DstScalarBits < 64 ? 3 : 4);
921 if (Opcode == Instruction::ZExt)
929 else if (isInt128InVR(Dst)) {
932 if (Opcode == Instruction::ZExt &&
I !=
nullptr)
933 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
940 if (Opcode == Instruction::Trunc && isInt128InVR(Src) &&
I !=
nullptr) {
941 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
944 bool OnlyTruncatingStores =
true;
945 for (
const User *U :
I->users())
946 if (!isa<StoreInst>(U)) {
947 OnlyTruncatingStores =
false;
950 if (OnlyTruncatingStores)
955 else if (ST->hasVector()) {
957 auto *SrcVecTy = cast<FixedVectorType>(Src);
958 auto *DstVecTy = dyn_cast<FixedVectorType>(Dst);
963 unsigned VF = SrcVecTy->getNumElements();
967 if (Opcode == Instruction::Trunc) {
968 if (Src->getScalarSizeInBits() == Dst->getScalarSizeInBits())
973 if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt) {
974 if (SrcScalarBits >= 8) {
976 if (Opcode == Instruction::ZExt)
977 return NumDstVectors;
984 unsigned NumSrcVectorOps =
985 (NumUnpacks > 1 ? (NumDstVectors - NumSrcVectors)
986 : (NumDstVectors / 2));
988 return (NumUnpacks * NumDstVectors) + NumSrcVectorOps;
990 else if (SrcScalarBits == 1)
994 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP ||
995 Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) {
1000 if (DstScalarBits == 64 || ST->hasVectorEnhancements2()) {
1001 if (SrcScalarBits == DstScalarBits)
1002 return NumDstVectors;
1004 if (SrcScalarBits == 1)
1012 Opcode, Dst->getScalarType(), Src->getScalarType(), CCH,
CostKind);
1014 bool NeedsInserts =
true, NeedsExtracts =
true;
1016 if (DstScalarBits == 128 &&
1017 (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP))
1018 NeedsInserts =
false;
1019 if (SrcScalarBits == 128 &&
1020 (Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI))
1021 NeedsExtracts =
false;
1029 if (VF == 2 && SrcScalarBits == 32 && DstScalarBits == 32)
1035 if (Opcode == Instruction::FPTrunc) {
1036 if (SrcScalarBits == 128)
1041 return VF / 2 + std::max(1U, VF / 4 );
1044 if (Opcode == Instruction::FPExt) {
1045 if (SrcScalarBits == 32 && DstScalarBits == 64) {
1063 unsigned ExtCost = 0;
1066 if (!isa<LoadInst>(
Op) && !isa<ConstantInt>(
Op))
1082 case Instruction::ICmp: {
1086 if (
I !=
nullptr && (ScalarBits == 32 || ScalarBits == 64))
1087 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
1088 if (
const ConstantInt *
C = dyn_cast<ConstantInt>(
I->getOperand(1)))
1089 if (!Ld->hasOneUse() && Ld->getParent() ==
I->getParent() &&
1098 case Instruction::Select:
1105 if (
ICmpInst *CI = dyn_cast<ICmpInst>(
I->getOperand(0)))
1106 if (CI->getOperand(0)->getType()->isIntegerTy(128))
1107 return ST->hasVectorEnhancements3() ? 1 : 4;
1110 return !isInt128InVR(ValTy) ? 1 : 4;
1113 else if (ST->hasVector()) {
1114 unsigned VF = cast<FixedVectorType>(ValTy)->getNumElements();
1117 if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
1118 unsigned PredicateExtraCost = 0;
1121 switch (cast<CmpInst>(
I)->getPredicate()) {
1127 PredicateExtraCost = 1;
1133 PredicateExtraCost = 2;
1145 unsigned Cost = (NumVecs_cmp * (CmpCostPerVector + PredicateExtraCost));
1149 assert (Opcode == Instruction::Select);
1153 unsigned PackCost = 0;
1155 if (CmpOpTy !=
nullptr)
1169 unsigned Index,
Value *Op0,
1171 if (Opcode == Instruction::InsertElement) {
1180 return ((Index % 2 == 0) ? 1 : 0);
1183 if (Opcode == Instruction::ExtractElement) {
1204 unsigned TruncBits = 0;
1205 unsigned SExtBits = 0;
1206 unsigned ZExtBits = 0;
1209 if (isa<TruncInst>(UserI))
1210 TruncBits = UserBits;
1211 else if (isa<SExtInst>(UserI))
1212 SExtBits = UserBits;
1213 else if (isa<ZExtInst>(UserI))
1214 ZExtBits = UserBits;
1216 if (TruncBits || SExtBits || ZExtBits) {
1217 FoldedValue = UserI;
1218 UserI = cast<Instruction>(*UserI->
user_begin());
1221 if ((UserI->
getOpcode() == Instruction::Sub ||
1222 UserI->
getOpcode() == Instruction::SDiv ||
1223 UserI->
getOpcode() == Instruction::UDiv) &&
1228 unsigned LoadOrTruncBits =
1229 ((SExtBits || ZExtBits) ? 0 : (TruncBits ? TruncBits : LoadedBits));
1231 case Instruction::Add:
1232 case Instruction::Sub:
1233 case Instruction::ICmp:
1234 if (LoadedBits == 32 && ZExtBits == 64)
1237 case Instruction::Mul:
1238 if (UserI->
getOpcode() != Instruction::ICmp) {
1239 if (LoadedBits == 16 &&
1241 (SExtBits == 64 && ST->hasMiscellaneousExtensions2())))
1243 if (LoadOrTruncBits == 16)
1247 case Instruction::SDiv:
1248 if (LoadedBits == 32 && SExtBits == 64)
1251 case Instruction::UDiv:
1252 case Instruction::And:
1253 case Instruction::Or:
1254 case Instruction::Xor:
1266 if (UserI->
getOpcode() == Instruction::ICmp)
1268 if (CI->getValue().isIntN(16))
1270 return (LoadOrTruncBits == 32 || LoadOrTruncBits == 64);
1278 if (
auto *CI = dyn_cast<CallInst>(
I))
1279 if (
auto *
F = CI->getCalledFunction())
1280 if (
F->getIntrinsicID() == Intrinsic::bswap)
1291 assert(!Src->isVoidTy() &&
"Invalid type");
1297 if (!Src->isVectorTy() && Opcode == Instruction::Load &&
I !=
nullptr) {
1306 for (
unsigned i = 0; i < 2; ++i) {
1311 LoadInst *OtherLoad = dyn_cast<LoadInst>(OtherOp);
1313 (isa<TruncInst>(OtherOp) || isa<SExtInst>(OtherOp) ||
1314 isa<ZExtInst>(OtherOp)))
1315 OtherLoad = dyn_cast<LoadInst>(OtherOp->getOperand(0));
1331 if (Src->isFP128Ty() && !ST->hasVectorEnhancements1())
1338 if (((!Src->isVectorTy() && NumOps == 1) || ST->hasVectorEnhancements2()) &&
1340 if (Opcode == Instruction::Load &&
I->hasOneUse()) {
1341 const Instruction *LdUser = cast<Instruction>(*
I->user_begin());
1347 else if (
const StoreInst *SI = dyn_cast<StoreInst>(
I)) {
1348 const Value *StoredVal = SI->getValueOperand();
1365 bool UseMaskForCond,
bool UseMaskForGaps) {
1366 if (UseMaskForCond || UseMaskForGaps)
1369 UseMaskForCond, UseMaskForGaps);
1370 assert(isa<VectorType>(VecTy) &&
1371 "Expect a vector type for interleaved memory op");
1373 unsigned NumElts = cast<FixedVectorType>(VecTy)->getNumElements();
1374 assert(Factor > 1 && NumElts % Factor == 0 &&
"Invalid interleave factor");
1375 unsigned VF = NumElts / Factor;
1378 unsigned NumPermutes = 0;
1380 if (Opcode == Instruction::Load) {
1384 BitVector UsedInsts(NumVectorMemOps,
false);
1385 std::vector<BitVector> ValueVecs(Factor,
BitVector(NumVectorMemOps,
false));
1386 for (
unsigned Index : Indices)
1387 for (
unsigned Elt = 0; Elt < VF; ++Elt) {
1388 unsigned Vec = (Index + Elt * Factor) / NumEltsPerVecReg;
1390 ValueVecs[Index].
set(Vec);
1392 NumVectorMemOps = UsedInsts.
count();
1394 for (
unsigned Index : Indices) {
1398 unsigned NumSrcVecs = ValueVecs[Index].count();
1400 assert (NumSrcVecs >= NumDstVecs &&
"Expected at least as many sources");
1401 NumPermutes += std::max(1U, NumSrcVecs - NumDstVecs);
1407 unsigned NumSrcVecs = std::min(NumEltsPerVecReg, Factor);
1408 unsigned NumDstVecs = NumVectorMemOps;
1409 NumPermutes += (NumDstVecs * NumSrcVecs) - NumDstVecs;
1413 return NumVectorMemOps + NumPermutes;
1421 Cost += (ScalarBits < 32) ? 3 : 2;
1426 unsigned ScalarBits) {
1438 return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
1439 Opcode == Instruction::Add || Opcode == Instruction::Mul;
1444 std::optional<FastMathFlags> FMF,
1455 if (Opcode == Instruction::Add)
1461 if ((Opcode == Instruction::FAdd) || (Opcode == Instruction::FMul))
1474 if (ST->hasVectorEnhancements1()) {
1480 Cost += NumVectors - 1;
1493 if (
RetTy->isVectorTy() &&
ID == Intrinsic::bswap)
1511 if (!ST->hasVector())
1515 switch (
II->getIntrinsicID()) {
1519 case Intrinsic::vector_reduce_add:
1520 auto *VType = cast<FixedVectorType>(
II->getOperand(0)->getType());
1524 return VType->getScalarSizeInBits() >= 64 ||
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static cl::opt< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const HexagonInstrInfo * TII
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
static const Function * getCalledFunction(const Value *V)
uint64_t IntrinsicInst * II
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getNumElements(Type *Ty)
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
Get intrinsic cost based on arguments.
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
unsigned getNumberOfParts(Type *Tp)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *Ty, int &Index, VectorType *&SubTy) const
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
Try to calculate op costs for min/max reduction operations.
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)
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr)
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getScalarizationOverhead(VectorType *InTy, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, ArrayRef< Value * > VL={})
Estimate the overhead of scalarizing an instruction.
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 *CxtI=nullptr)
size_type count() const
count - Returns the number of bits which are set.
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.
This class represents an Operation in the Expression.
Convenience struct for specifying and reasoning about fast-math flags.
Class to represent fixed width SIMD vectors.
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
This instruction compares its operands according to the predicate given to the constructor.
std::optional< CostType > getValue() const
This function is intended to be used as sparingly as possible, since the class provides the full rang...
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.
A Module instance is used to store all the information related to an LLVM module.
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.
const SystemZInstrInfo * getInstrInfo() const override
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
bool shouldExpandReduction(const IntrinsicInst *II) const
unsigned getNumberOfRegisters(unsigned ClassID) const
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)
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
unsigned getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, const Instruction *I)
unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const override
unsigned adjustInliningThreshold(const CallBase *CB) const
unsigned getVectorTruncCost(Type *SrcTy, Type *DstTy)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
bool isFoldableLoad(const LoadInst *Ld, const Instruction *&FoldedValue)
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, ArrayRef< Value * > VL={})
unsigned getVectorBitmaskConversionCost(Type *SrcTy, Type *DstTy)
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
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 *CxtI=nullptr)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr)
bool hasDivRemOp(Type *DataType, bool IsSigned)
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
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.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isFP128Ty() const
Return true if this is 'fp128'.
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 isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
user_iterator user_begin()
bool hasOneUse() const
Return true if there is exactly one use of this value.
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
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.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
@ Global
Append to llvm.global_dtors.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
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.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.