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) && VF > 4)
662 if (Opcode == Instruction::FAdd || Opcode == Instruction::FSub ||
663 Opcode == Instruction::FMul || Opcode == Instruction::FDiv) {
664 switch (ScalarBits) {
667 if (ST->hasVectorEnhancements1())
692 if (Opcode == Instruction::FRem) {
695 (VF * LIBCALL_COST) +
698 if (VF == 2 && ScalarBits == 32)
714 if (ST->hasVector()) {
730 return (Index == 0 ? 0 : NumVectors);
737 return NumVectors - 1;
766 "Packing must reduce size of vector type.");
769 "Packing should not change number of elements.");
784 unsigned VF = cast<FixedVectorType>(SrcTy)->getNumElements();
785 for (
unsigned P = 0;
P < Log2Diff; ++
P) {
806 "Should only be called with vector types.");
808 unsigned PackCost = 0;
812 if (SrcScalarBits > DstScalarBits)
815 else if (SrcScalarBits < DstScalarBits) {
818 PackCost = Log2Diff * DstNumParts;
820 PackCost += DstNumParts - 1;
829 Type *OpTy =
nullptr;
830 if (
CmpInst *CI = dyn_cast<CmpInst>(
I->getOperand(0)))
831 OpTy = CI->getOperand(0)->getType();
832 else if (
Instruction *LogicI = dyn_cast<Instruction>(
I->getOperand(0)))
833 if (LogicI->getNumOperands() == 2)
834 if (
CmpInst *CI0 = dyn_cast<CmpInst>(LogicI->getOperand(0)))
835 if (isa<CmpInst>(LogicI->getOperand(1)))
836 OpTy = CI0->getOperand(0)->getType();
838 if (OpTy !=
nullptr) {
857 auto *DstVTy = cast<FixedVectorType>(Dst);
858 unsigned VF = DstVTy->getNumElements();
863 if (CmpOpTy !=
nullptr)
865 if (Opcode == Instruction::ZExt || Opcode == Instruction::UIToFP)
879 return BaseCost == 0 ? BaseCost : 1;
882 unsigned DstScalarBits = Dst->getScalarSizeInBits();
883 unsigned SrcScalarBits = Src->getScalarSizeInBits();
885 if (!Src->isVectorTy()) {
886 assert (!Dst->isVectorTy());
888 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP) {
889 if (Src->isIntegerTy(128))
891 if (SrcScalarBits >= 32 ||
892 (
I !=
nullptr && isa<LoadInst>(
I->getOperand(0))))
894 return SrcScalarBits > 1 ? 2 : 5 ;
897 if ((Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) &&
898 Dst->isIntegerTy(128))
901 if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt)) {
902 if (Src->isIntegerTy(1)) {
903 if (DstScalarBits == 128)
906 if (ST->hasLoadStoreOnCond2())
912 if (Opcode == Instruction::SExt)
913 Cost = (DstScalarBits < 64 ? 3 : 4);
914 if (Opcode == Instruction::ZExt)
922 else if (isInt128InVR(Dst)) {
925 if (Opcode == Instruction::ZExt &&
I !=
nullptr)
926 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
933 if (Opcode == Instruction::Trunc && isInt128InVR(Src) &&
I !=
nullptr) {
934 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
937 bool OnlyTruncatingStores =
true;
938 for (
const User *U :
I->users())
939 if (!isa<StoreInst>(U)) {
940 OnlyTruncatingStores =
false;
943 if (OnlyTruncatingStores)
948 else if (ST->hasVector()) {
950 auto *SrcVecTy = cast<FixedVectorType>(Src);
951 auto *DstVecTy = dyn_cast<FixedVectorType>(Dst);
956 unsigned VF = SrcVecTy->getNumElements();
960 if (Opcode == Instruction::Trunc) {
961 if (Src->getScalarSizeInBits() == Dst->getScalarSizeInBits())
966 if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt) {
967 if (SrcScalarBits >= 8) {
969 if (Opcode == Instruction::ZExt)
970 return NumDstVectors;
977 unsigned NumSrcVectorOps =
978 (NumUnpacks > 1 ? (NumDstVectors - NumSrcVectors)
979 : (NumDstVectors / 2));
981 return (NumUnpacks * NumDstVectors) + NumSrcVectorOps;
983 else if (SrcScalarBits == 1)
987 if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP ||
988 Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI) {
993 if (DstScalarBits == 64 || ST->hasVectorEnhancements2()) {
994 if (SrcScalarBits == DstScalarBits)
995 return NumDstVectors;
997 if (SrcScalarBits == 1)
1005 Opcode, Dst->getScalarType(), Src->getScalarType(), CCH,
CostKind);
1007 bool NeedsInserts =
true, NeedsExtracts =
true;
1009 if (DstScalarBits == 128 &&
1010 (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP))
1011 NeedsInserts =
false;
1012 if (SrcScalarBits == 128 &&
1013 (Opcode == Instruction::FPToSI || Opcode == Instruction::FPToUI))
1014 NeedsExtracts =
false;
1022 if (VF == 2 && SrcScalarBits == 32 && DstScalarBits == 32)
1028 if (Opcode == Instruction::FPTrunc) {
1029 if (SrcScalarBits == 128)
1034 return VF / 2 + std::max(1U, VF / 4 );
1037 if (Opcode == Instruction::FPExt) {
1038 if (SrcScalarBits == 32 && DstScalarBits == 64) {
1056 unsigned ExtCost = 0;
1059 if (!isa<LoadInst>(
Op) && !isa<ConstantInt>(
Op))
1075 case Instruction::ICmp: {
1079 if (
I !=
nullptr && (ScalarBits == 32 || ScalarBits == 64))
1080 if (
LoadInst *Ld = dyn_cast<LoadInst>(
I->getOperand(0)))
1081 if (
const ConstantInt *
C = dyn_cast<ConstantInt>(
I->getOperand(1)))
1082 if (!Ld->hasOneUse() && Ld->getParent() ==
I->getParent() &&
1091 case Instruction::Select:
1097 else if (ST->hasVector()) {
1098 unsigned VF = cast<FixedVectorType>(ValTy)->getNumElements();
1101 if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
1102 unsigned PredicateExtraCost = 0;
1105 switch (cast<CmpInst>(
I)->getPredicate()) {
1111 PredicateExtraCost = 1;
1117 PredicateExtraCost = 2;
1129 unsigned Cost = (NumVecs_cmp * (CmpCostPerVector + PredicateExtraCost));
1133 assert (Opcode == Instruction::Select);
1137 unsigned PackCost = 0;
1139 if (CmpOpTy !=
nullptr)
1153 unsigned Index,
Value *Op0,
1155 if (Opcode == Instruction::InsertElement) {
1164 return ((Index % 2 == 0) ? 1 : 0);
1167 if (Opcode == Instruction::ExtractElement) {
1188 unsigned TruncBits = 0;
1189 unsigned SExtBits = 0;
1190 unsigned ZExtBits = 0;
1193 if (isa<TruncInst>(UserI))
1194 TruncBits = UserBits;
1195 else if (isa<SExtInst>(UserI))
1196 SExtBits = UserBits;
1197 else if (isa<ZExtInst>(UserI))
1198 ZExtBits = UserBits;
1200 if (TruncBits || SExtBits || ZExtBits) {
1201 FoldedValue = UserI;
1202 UserI = cast<Instruction>(*UserI->
user_begin());
1205 if ((UserI->
getOpcode() == Instruction::Sub ||
1206 UserI->
getOpcode() == Instruction::SDiv ||
1207 UserI->
getOpcode() == Instruction::UDiv) &&
1212 unsigned LoadOrTruncBits =
1213 ((SExtBits || ZExtBits) ? 0 : (TruncBits ? TruncBits : LoadedBits));
1215 case Instruction::Add:
1216 case Instruction::Sub:
1217 case Instruction::ICmp:
1218 if (LoadedBits == 32 && ZExtBits == 64)
1221 case Instruction::Mul:
1222 if (UserI->
getOpcode() != Instruction::ICmp) {
1223 if (LoadedBits == 16 &&
1225 (SExtBits == 64 && ST->hasMiscellaneousExtensions2())))
1227 if (LoadOrTruncBits == 16)
1231 case Instruction::SDiv:
1232 if (LoadedBits == 32 && SExtBits == 64)
1235 case Instruction::UDiv:
1236 case Instruction::And:
1237 case Instruction::Or:
1238 case Instruction::Xor:
1250 if (UserI->
getOpcode() == Instruction::ICmp)
1252 if (CI->getValue().isIntN(16))
1254 return (LoadOrTruncBits == 32 || LoadOrTruncBits == 64);
1262 if (
auto *CI = dyn_cast<CallInst>(
I))
1263 if (
auto *
F = CI->getCalledFunction())
1264 if (
F->getIntrinsicID() == Intrinsic::bswap)
1275 assert(!Src->isVoidTy() &&
"Invalid type");
1281 if (!Src->isVectorTy() && Opcode == Instruction::Load &&
I !=
nullptr) {
1290 for (
unsigned i = 0; i < 2; ++i) {
1295 LoadInst *OtherLoad = dyn_cast<LoadInst>(OtherOp);
1297 (isa<TruncInst>(OtherOp) || isa<SExtInst>(OtherOp) ||
1298 isa<ZExtInst>(OtherOp)))
1299 OtherLoad = dyn_cast<LoadInst>(OtherOp->getOperand(0));
1315 if (Src->isFP128Ty() && !ST->hasVectorEnhancements1())
1322 if (((!Src->isVectorTy() && NumOps == 1) || ST->hasVectorEnhancements2()) &&
1324 if (Opcode == Instruction::Load &&
I->hasOneUse()) {
1325 const Instruction *LdUser = cast<Instruction>(*
I->user_begin());
1331 else if (
const StoreInst *SI = dyn_cast<StoreInst>(
I)) {
1332 const Value *StoredVal = SI->getValueOperand();
1349 bool UseMaskForCond,
bool UseMaskForGaps) {
1350 if (UseMaskForCond || UseMaskForGaps)
1353 UseMaskForCond, UseMaskForGaps);
1354 assert(isa<VectorType>(VecTy) &&
1355 "Expect a vector type for interleaved memory op");
1357 unsigned NumElts = cast<FixedVectorType>(VecTy)->getNumElements();
1358 assert(Factor > 1 && NumElts % Factor == 0 &&
"Invalid interleave factor");
1359 unsigned VF = NumElts / Factor;
1362 unsigned NumPermutes = 0;
1364 if (Opcode == Instruction::Load) {
1368 BitVector UsedInsts(NumVectorMemOps,
false);
1369 std::vector<BitVector> ValueVecs(Factor,
BitVector(NumVectorMemOps,
false));
1370 for (
unsigned Index : Indices)
1371 for (
unsigned Elt = 0; Elt < VF; ++Elt) {
1372 unsigned Vec = (Index + Elt * Factor) / NumEltsPerVecReg;
1374 ValueVecs[Index].
set(Vec);
1376 NumVectorMemOps = UsedInsts.
count();
1378 for (
unsigned Index : Indices) {
1382 unsigned NumSrcVecs = ValueVecs[Index].count();
1384 assert (NumSrcVecs >= NumDstVecs &&
"Expected at least as many sources");
1385 NumPermutes += std::max(1U, NumSrcVecs - NumDstVecs);
1391 unsigned NumSrcVecs = std::min(NumEltsPerVecReg, Factor);
1392 unsigned NumDstVecs = NumVectorMemOps;
1393 NumPermutes += (NumDstVecs * NumSrcVecs) - NumDstVecs;
1397 return NumVectorMemOps + NumPermutes;
1405 Cost += (ScalarBits < 32) ? 3 : 2;
1410 unsigned ScalarBits) {
1422 return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
1423 Opcode == Instruction::Add || Opcode == Instruction::Mul;
1428 std::optional<FastMathFlags> FMF,
1439 if (Opcode == Instruction::Add)
1445 if ((Opcode == Instruction::FAdd) || (Opcode == Instruction::FMul))
1458 if (ST->hasVectorEnhancements1()) {
1464 Cost += NumVectors - 1;
1477 if (
RetTy->isVectorTy() &&
ID == Intrinsic::bswap)
1495 if (!ST->hasVector())
1499 switch (
II->getIntrinsicID()) {
1503 case Intrinsic::vector_reduce_add:
1504 auto *VType = cast<FixedVectorType>(
II->getOperand(0)->getType());
1508 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)
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.