16#ifndef LLVM_CODEGEN_BASICTTIIMPL_H
17#define LLVM_CODEGEN_BASICTTIIMPL_H
86 T *thisT() {
return static_cast<T *
>(
this); }
95 Cost += thisT()->getVectorInstrCost(Instruction::ExtractElement, VTy,
99 Cost += thisT()->getVectorInstrCost(Instruction::InsertElement, VTy,
118 Cost += thisT()->getVectorInstrCost(Instruction::InsertElement, VTy,
120 Cost += thisT()->getVectorInstrCost(Instruction::ExtractElement, VTy,
133 "Can only extract subvectors from vectors");
135 assert((!isa<FixedVectorType>(VTy) ||
136 (
Index + NumSubElts) <=
138 "SK_ExtractSubvector index out of range");
144 for (
int i = 0; i != NumSubElts; ++i) {
146 thisT()->getVectorInstrCost(Instruction::ExtractElement, VTy,
148 Cost += thisT()->getVectorInstrCost(Instruction::InsertElement, SubVTy,
161 "Can only insert subvectors into vectors");
163 assert((!isa<FixedVectorType>(VTy) ||
164 (
Index + NumSubElts) <=
166 "SK_InsertSubvector index out of range");
172 for (
int i = 0; i != NumSubElts; ++i) {
173 Cost += thisT()->getVectorInstrCost(Instruction::ExtractElement, SubVTy,
176 thisT()->getVectorInstrCost(Instruction::InsertElement, VTy,
CostKind,
177 i +
Index,
nullptr,
nullptr);
184 return static_cast<const T *
>(
this)->getST();
189 return static_cast<const T *
>(
this)->getTLI();
211 bool IsGatherScatter,
215 if (isa<ScalableVectorType>(DataTy))
218 auto *VT = cast<FixedVectorType>(DataTy);
219 unsigned VF = VT->getNumElements();
234 VF * thisT()->getMemoryOpCost(Opcode, VT->getElementType(), Alignment,
240 Opcode == Instruction::Store,
CostKind);
254 VF * (thisT()->getCFInstrCost(Instruction::Br,
CostKind) +
255 thisT()->getCFInstrCost(Instruction::PHI,
CostKind));
258 return AddrExtractCost + MemoryOpCost + PackingCost + ConditionalCost;
268 bool IsCompared =
false;
272 return P.index() != Mask.size() - 1 || IsCompared;
273 if (
static_cast<unsigned>(
P.value()) >= NumSrcElts * 2)
276 SplatIdx =
P.value();
277 return P.index() != Mask.size() - 1;
280 return SplatIdx ==
P.value();
300 unsigned *
Fast)
const {
311 TM.getSubtargetImpl(*Caller)->getFeatureBits();
313 TM.getSubtargetImpl(*Callee)->getFeatureBits();
317 return (CallerBits & CalleeBits) == CalleeBits;
357 std::pair<const Value *, unsigned>
380 bool HasBaseReg, int64_t Scale,
unsigned AddrSpace,
382 int64_t ScalableOffset = 0) {
397 Type *ScalarValTy)
const {
398 auto &&IsSupportedByTarget = [
this, ScalarMemTy, ScalarValTy](
unsigned VF) {
401 if (getTLI()->isOperationLegal(
ISD::STORE, VT) ||
411 while (VF > 2 && IsSupportedByTarget(VF))
446 int64_t Scale,
unsigned AddrSpace) {
485 unsigned &JumpTableSize,
495 unsigned N = SI.getNumCases();
500 bool IsJTAllowed = TLI->
areJTsAllowed(SI.getParent()->getParent());
506 APInt MaxCaseVal = SI.case_begin()->getCaseValue()->getValue();
507 APInt MinCaseVal = MaxCaseVal;
508 for (
auto CI : SI.cases()) {
509 const APInt &CaseVal = CI.getCaseValue()->getValue();
510 if (CaseVal.
sgt(MaxCaseVal))
511 MaxCaseVal = CaseVal;
512 if (CaseVal.
slt(MinCaseVal))
513 MinCaseVal = CaseVal;
519 for (
auto I : SI.cases())
520 Dests.
insert(
I.getCaseSuccessor());
529 if (
N < 2 || N < TLI->getMinimumJumpTableEntries())
532 (MaxCaseVal - MinCaseVal)
533 .getLimitedValue(std::numeric_limits<uint64_t>::max() - 1) + 1;
536 JumpTableSize =
Range;
552 if (!TM.isPositionIndependent())
562 const Triple &TargetTriple = TM.getTargetTriple();
600 case Instruction::SDiv:
601 case Instruction::SRem:
602 case Instruction::UDiv:
603 case Instruction::URem: {
652 else if (ST->getSchedModel().LoopMicroOpBufferSize > 0)
653 MaxOps = ST->getSchedModel().LoopMicroOpBufferSize;
660 if (isa<CallInst>(
I) || isa<InvokeInst>(
I)) {
670 <<
"advising against unrolling the loop because it "
727 std::optional<Value *>
730 bool &KnownBitsComputed) {
741 IC,
II, DemandedElts, UndefElts, UndefElts2, UndefElts3,
745 virtual std::optional<unsigned>
747 return std::optional<unsigned>(
751 virtual std::optional<unsigned>
753 std::optional<unsigned> TargetResult =
771 unsigned NumStridedMemAccesses,
772 unsigned NumPrefetches,
773 bool HasCall)
const {
775 NumPrefetches, HasCall);
807 const APInt &DemandedElts,
808 bool Insert,
bool Extract,
813 if (isa<ScalableVectorType>(InTy))
815 auto *Ty = cast<FixedVectorType>(InTy);
818 (VL.empty() || VL.size() == Ty->getNumElements()) &&
819 "Vector size mismatch");
823 for (
int i = 0, e = Ty->getNumElements(); i < e; ++i) {
824 if (!DemandedElts[i])
827 Value *InsertedVal = VL.empty() ? nullptr : VL[i];
828 Cost += thisT()->getVectorInstrCost(Instruction::InsertElement, Ty,
832 Cost += thisT()->getVectorInstrCost(Instruction::ExtractElement, Ty,
844 unsigned ScalarOpdIdx)
const {
862 if (isa<ScalableVectorType>(InTy))
864 auto *Ty = cast<FixedVectorType>(InTy);
867 return thisT()->getScalarizationOverhead(Ty, DemandedElts, Insert, Extract,
878 assert(Args.size() == Tys.size() &&
"Expected matching Args and Tys");
882 for (
int I = 0,
E = Args.size();
I !=
E;
I++) {
890 if (!isa<Constant>(
A) && UniqueOperands.
insert(
A).second) {
891 if (
auto *VecTy = dyn_cast<VectorType>(Ty))
948 if (MTy == LK.second)
962 ArrayRef<const Value *> Args = {},
const Instruction *CxtI =
nullptr) {
964 const TargetLoweringBase *TLI = getTLI();
965 int ISD = TLI->InstructionOpcodeToISD(Opcode);
966 assert(ISD &&
"Invalid opcode");
979 InstructionCost OpCost = (IsFloat ? 2 : 1);
981 if (TLI->isOperationLegalOrPromote(ISD,
LT.second)) {
984 return LT.first * OpCost;
987 if (!TLI->isOperationExpand(ISD,
LT.second)) {
990 return LT.first * 2 * OpCost;
1002 unsigned DivOpc = IsSigned ? Instruction::SDiv : Instruction::UDiv;
1003 InstructionCost DivCost = thisT()->getArithmeticInstrCost(
1004 DivOpc, Ty,
CostKind, Opd1Info, Opd2Info);
1005 InstructionCost MulCost =
1006 thisT()->getArithmeticInstrCost(Instruction::Mul, Ty,
CostKind);
1007 InstructionCost SubCost =
1008 thisT()->getArithmeticInstrCost(Instruction::Sub, Ty,
CostKind);
1009 return DivCost + MulCost + SubCost;
1014 if (isa<ScalableVectorType>(Ty))
1020 if (
auto *VTy = dyn_cast<FixedVectorType>(Ty)) {
1021 InstructionCost
Cost = thisT()->getArithmeticInstrCost(
1026 SmallVector<Type *>
Tys(
Args.size(), Ty);
1048 if (isSplatMask(Mask, NumSrcElts,
Index))
1051 (
Index + Mask.size()) <= (
size_t)NumSrcElts) {
1060 Mask, NumSrcElts, NumSubElts,
Index)) {
1061 if (
Index + NumSubElts > NumSrcElts)
1094 if (
auto *FVT = dyn_cast<FixedVectorType>(Tp))
1095 return getBroadcastShuffleOverhead(FVT,
CostKind);
1103 if (
auto *FVT = dyn_cast<FixedVectorType>(Tp))
1104 return getPermuteShuffleOverhead(FVT,
CostKind);
1108 cast<FixedVectorType>(SubTp));
1111 cast<FixedVectorType>(SubTp));
1125 assert(ISD &&
"Invalid opcode");
1129 TypeSize SrcSize = SrcLT.second.getSizeInBits();
1130 TypeSize DstSize = DstLT.second.getSizeInBits();
1131 bool IntOrPtrSrc = Src->isIntegerTy() || Src->isPointerTy();
1132 bool IntOrPtrDst = Dst->isIntegerTy() || Dst->isPointerTy();
1137 case Instruction::Trunc:
1142 case Instruction::BitCast:
1145 if (SrcLT.first == DstLT.first && IntOrPtrSrc == IntOrPtrDst &&
1149 case Instruction::FPExt:
1150 if (
I && getTLI()->isExtFree(
I))
1153 case Instruction::ZExt:
1154 if (TLI->
isZExtFree(SrcLT.second, DstLT.second))
1157 case Instruction::SExt:
1158 if (
I && getTLI()->isExtFree(
I))
1168 if (DstLT.first == SrcLT.first &&
1173 case Instruction::AddrSpaceCast:
1175 Dst->getPointerAddressSpace()))
1180 auto *SrcVTy = dyn_cast<VectorType>(Src);
1181 auto *DstVTy = dyn_cast<VectorType>(Dst);
1184 if (SrcLT.first == DstLT.first &&
1189 if (!SrcVTy && !DstVTy) {
1200 if (DstVTy && SrcVTy) {
1202 if (SrcLT.first == DstLT.first && SrcSize == DstSize) {
1205 if (Opcode == Instruction::ZExt)
1209 if (Opcode == Instruction::SExt)
1210 return SrcLT.first * 2;
1216 return SrcLT.first * 1;
1229 if ((SplitSrc || SplitDst) && SrcVTy->getElementCount().isVector() &&
1230 DstVTy->getElementCount().isVector()) {
1233 T *
TTI =
static_cast<T *
>(
this);
1236 (!SplitSrc || !SplitDst) ?
TTI->getVectorSplitCost() : 0;
1243 if (isa<ScalableVectorType>(DstVTy))
1248 unsigned Num = cast<FixedVectorType>(DstVTy)->getNumElements();
1250 Opcode, Dst->getScalarType(), Src->getScalarType(), CCH,
CostKind,
I);
1263 if (Opcode == Instruction::BitCast) {
1279 return thisT()->getVectorInstrCost(Instruction::ExtractElement, VecTy,
1295 const Instruction *
I =
nullptr) {
1296 const TargetLoweringBase *TLI = getTLI();
1297 int ISD = TLI->InstructionOpcodeToISD(Opcode);
1298 assert(ISD &&
"Invalid opcode");
1303 Op1Info, Op2Info,
I);
1307 assert(CondTy &&
"CondTy must exist");
1314 !TLI->isOperationExpand(ISD,
LT.second)) {
1317 return LT.first * 1;
1323 if (
auto *ValVTy = dyn_cast<VectorType>(ValTy)) {
1324 if (isa<ScalableVectorType>(ValTy))
1327 unsigned Num = cast<FixedVectorType>(ValVTy)->getNumElements();
1330 InstructionCost
Cost =
1331 thisT()->getCmpSelInstrCost(Opcode, ValVTy->getScalarType(), CondTy,
1332 VecPred,
CostKind, Op1Info, Op2Info,
I);
1358 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) {
1359 return thisT()->getVectorInstrCost(Opcode, Val,
CostKind,
Index,
nullptr,
1366 Value *Op0 =
nullptr;
1367 Value *Op1 =
nullptr;
1368 if (
auto *IE = dyn_cast<InsertElementInst>(&
I)) {
1369 Op0 = IE->getOperand(0);
1370 Op1 = IE->getOperand(1);
1372 return thisT()->getVectorInstrCost(
I.getOpcode(), Val,
CostKind,
Index, Op0,
1378 const APInt &DemandedDstElts,
1381 "Unexpected size of DemandedDstElts.");
1399 Cost += thisT()->getScalarizationOverhead(SrcVT, DemandedSrcElts,
1402 Cost += thisT()->getScalarizationOverhead(ReplicatedVT, DemandedDstElts,
1414 assert(!Src->isVoidTy() &&
"Invalid type");
1431 LT.second.getSizeInBits())) {
1437 if (Opcode == Instruction::Store)
1446 cast<VectorType>(Src), Opcode != Instruction::Store,
1447 Opcode == Instruction::Store,
CostKind);
1458 return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment,
true,
false,
1463 const Value *
Ptr,
bool VariableMask,
1467 return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, VariableMask,
1472 unsigned Opcode,
Type *DataTy,
bool VariableMask,
Align Alignment,
1476 return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, VariableMask,
1481 const Value *
Ptr,
bool VariableMask,
1488 return thisT()->getGatherScatterOpCost(Opcode, DataTy,
Ptr, VariableMask,
1495 bool UseMaskForCond =
false,
bool UseMaskForGaps =
false) {
1498 if (isa<ScalableVectorType>(VecTy))
1501 auto *VT = cast<FixedVectorType>(VecTy);
1503 unsigned NumElts = VT->getNumElements();
1504 assert(Factor > 1 && NumElts % Factor == 0 &&
"Invalid interleave factor");
1506 unsigned NumSubElts = NumElts / Factor;
1511 if (UseMaskForCond || UseMaskForGaps)
1512 Cost = thisT()->getMaskedMemoryOpCost(Opcode, VecTy, Alignment,
1521 unsigned VecTySize = thisT()->getDataLayout().getTypeStoreSize(VecTy);
1541 unsigned NumLegalInsts =
divideCeil(VecTySize, VecTyLTSize);
1545 unsigned NumEltsPerLegalInst =
divideCeil(NumElts, NumLegalInsts);
1548 BitVector UsedInsts(NumLegalInsts,
false);
1549 for (
unsigned Index : Indices)
1550 for (
unsigned Elt = 0; Elt < NumSubElts; ++Elt)
1551 UsedInsts.
set((
Index + Elt * Factor) / NumEltsPerLegalInst);
1560 "Interleaved memory op has too many members");
1566 for (
unsigned Index : Indices) {
1567 assert(
Index < Factor &&
"Invalid index for interleaved memory op");
1568 for (
unsigned Elm = 0; Elm < NumSubElts; Elm++)
1569 DemandedLoadStoreElts.
setBit(
Index + Elm * Factor);
1572 if (Opcode == Instruction::Load) {
1582 SubVT, DemandedAllSubElts,
1584 Cost += Indices.
size() * InsSubCost;
1585 Cost += thisT()->getScalarizationOverhead(VT, DemandedLoadStoreElts,
1603 SubVT, DemandedAllSubElts,
1605 Cost += ExtSubCost * Indices.
size();
1606 Cost += thisT()->getScalarizationOverhead(VT, DemandedLoadStoreElts,
1611 if (!UseMaskForCond)
1616 Cost += thisT()->getReplicationShuffleCost(
1617 I8Type, Factor, NumSubElts,
1618 UseMaskForGaps ? DemandedLoadStoreElts : DemandedAllResultElts,
1626 if (UseMaskForGaps) {
1628 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::And, MaskVT,
1653 std::optional<unsigned> FOp =
1656 if (ICA.
getID() == Intrinsic::vp_load) {
1658 if (
auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.
getInst()))
1659 Alignment = VPI->getPointerAlignment().valueOrOne();
1662 if (
auto *PtrTy = dyn_cast<PointerType>(ICA.
getArgTypes()[0]))
1663 AS = PtrTy->getAddressSpace();
1664 return thisT()->getMemoryOpCost(*FOp, ICA.
getReturnType(), Alignment,
1667 if (ICA.
getID() == Intrinsic::vp_store) {
1669 if (
auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.
getInst()))
1670 Alignment = VPI->getPointerAlignment().valueOrOne();
1673 if (
auto *PtrTy = dyn_cast<PointerType>(ICA.
getArgTypes()[1]))
1674 AS = PtrTy->getAddressSpace();
1675 return thisT()->getMemoryOpCost(*FOp, ICA.
getArgTypes()[0], Alignment,
1679 return thisT()->getArithmeticInstrCost(*FOp, ICA.
getReturnType(),
1683 return thisT()->getCastInstrCost(
1691 auto *UI = cast<VPCmpIntrinsic>(ICA.
getInst());
1692 return thisT()->getCmpSelInstrCost(*FOp, ICA.
getArgTypes()[0],
1699 std::optional<Intrinsic::ID> FID =
1705 "Expected VPIntrinsic to have Mask and Vector Length args and "
1713 *FID != Intrinsic::vector_reduce_fadd &&
1714 *FID != Intrinsic::vector_reduce_fmul)
1719 return thisT()->getIntrinsicInstrCost(NewICA,
CostKind);
1729 (
RetTy->isVectorTy() ? cast<VectorType>(
RetTy)->getElementCount()
1738 case Intrinsic::powi:
1739 if (
auto *RHSC = dyn_cast<ConstantInt>(Args[1])) {
1740 bool ShouldOptForSize =
I->getParent()->getParent()->hasOptSize();
1742 ShouldOptForSize)) {
1746 unsigned ActiveBits =
Exponent.getActiveBits();
1747 unsigned PopCount =
Exponent.popcount();
1749 thisT()->getArithmeticInstrCost(
1751 if (RHSC->isNegative())
1752 Cost += thisT()->getArithmeticInstrCost(Instruction::FDiv,
RetTy,
1758 case Intrinsic::cttz:
1764 case Intrinsic::ctlz:
1770 case Intrinsic::memcpy:
1771 return thisT()->getMemcpyCost(ICA.
getInst());
1773 case Intrinsic::masked_scatter: {
1774 const Value *Mask = Args[3];
1775 bool VarMask = !isa<Constant>(Mask);
1776 Align Alignment = cast<ConstantInt>(Args[2])->getAlignValue();
1777 return thisT()->getGatherScatterOpCost(Instruction::Store,
1781 case Intrinsic::masked_gather: {
1782 const Value *Mask = Args[2];
1783 bool VarMask = !isa<Constant>(Mask);
1784 Align Alignment = cast<ConstantInt>(Args[1])->getAlignValue();
1785 return thisT()->getGatherScatterOpCost(Instruction::Load,
RetTy, Args[0],
1788 case Intrinsic::masked_compressstore: {
1790 const Value *Mask = Args[2];
1791 Align Alignment =
I->getParamAlign(1).valueOrOne();
1792 return thisT()->getExpandCompressMemoryOpCost(
1793 Instruction::Store,
Data->getType(), !isa<Constant>(Mask), Alignment,
1796 case Intrinsic::masked_expandload: {
1797 const Value *Mask = Args[1];
1798 Align Alignment =
I->getParamAlign(0).valueOrOne();
1799 return thisT()->getExpandCompressMemoryOpCost(Instruction::Load,
RetTy,
1800 !isa<Constant>(Mask),
1803 case Intrinsic::experimental_vp_strided_store: {
1806 const Value *Mask = Args[3];
1807 const Value *EVL = Args[4];
1808 bool VarMask = !isa<Constant>(Mask) || !isa<Constant>(EVL);
1809 Type *EltTy = cast<VectorType>(
Data->getType())->getElementType();
1812 return thisT()->getStridedMemoryOpCost(Instruction::Store,
1813 Data->getType(),
Ptr, VarMask,
1816 case Intrinsic::experimental_vp_strided_load: {
1818 const Value *Mask = Args[2];
1819 const Value *EVL = Args[3];
1820 bool VarMask = !isa<Constant>(Mask) || !isa<Constant>(EVL);
1821 Type *EltTy = cast<VectorType>(
RetTy)->getElementType();
1824 return thisT()->getStridedMemoryOpCost(Instruction::Load,
RetTy,
Ptr,
1827 case Intrinsic::stepvector: {
1828 if (isa<ScalableVectorType>(
RetTy))
1833 case Intrinsic::vector_extract: {
1836 if (isa<ScalableVectorType>(
RetTy))
1838 unsigned Index = cast<ConstantInt>(Args[1])->getZExtValue();
1840 cast<VectorType>(Args[0]->
getType()), {},
1843 case Intrinsic::vector_insert: {
1846 if (isa<ScalableVectorType>(Args[1]->
getType()))
1848 unsigned Index = cast<ConstantInt>(Args[2])->getZExtValue();
1849 return thisT()->getShuffleCost(
1853 case Intrinsic::vector_reverse: {
1855 cast<VectorType>(Args[0]->
getType()), {},
1858 case Intrinsic::vector_splice: {
1859 unsigned Index = cast<ConstantInt>(Args[2])->getZExtValue();
1861 cast<VectorType>(Args[0]->
getType()), {},
1864 case Intrinsic::vector_reduce_add:
1865 case Intrinsic::vector_reduce_mul:
1866 case Intrinsic::vector_reduce_and:
1867 case Intrinsic::vector_reduce_or:
1868 case Intrinsic::vector_reduce_xor:
1869 case Intrinsic::vector_reduce_smax:
1870 case Intrinsic::vector_reduce_smin:
1871 case Intrinsic::vector_reduce_fmax:
1872 case Intrinsic::vector_reduce_fmin:
1873 case Intrinsic::vector_reduce_fmaximum:
1874 case Intrinsic::vector_reduce_fminimum:
1875 case Intrinsic::vector_reduce_umax:
1876 case Intrinsic::vector_reduce_umin: {
1880 case Intrinsic::vector_reduce_fadd:
1881 case Intrinsic::vector_reduce_fmul: {
1883 IID,
RetTy, {Args[0]->getType(), Args[1]->
getType()}, FMF,
I, 1);
1886 case Intrinsic::fshl:
1887 case Intrinsic::fshr: {
1888 const Value *
X = Args[0];
1889 const Value *
Y = Args[1];
1890 const Value *Z = Args[2];
1903 thisT()->getArithmeticInstrCost(BinaryOperator::Or,
RetTy,
CostKind);
1905 thisT()->getArithmeticInstrCost(BinaryOperator::Sub,
RetTy,
CostKind);
1906 Cost += thisT()->getArithmeticInstrCost(
1909 Cost += thisT()->getArithmeticInstrCost(
1914 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::URem,
RetTy,
1918 Type *CondTy =
RetTy->getWithNewBitWidth(1);
1920 thisT()->getCmpSelInstrCost(BinaryOperator::ICmp,
RetTy, CondTy,
1923 thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy, CondTy,
1928 case Intrinsic::get_active_lane_mask: {
1934 if (!getTLI()->shouldExpandGetActiveLaneMask(ResVT, ArgType)) {
1944 thisT()->getTypeBasedIntrinsicInstrCost(Attrs,
CostKind);
1945 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, ExpRetTy,
RetTy,
1949 case Intrinsic::experimental_cttz_elts: {
1954 if (!getTLI()->shouldExpandCttzElements(ArgType))
1962 bool ZeroIsPoison = !cast<ConstantInt>(Args[1])->isZero();
1964 if (isa<ScalableVectorType>(ICA.
getArgTypes()[0]) &&
I &&
I->getCaller())
1973 NewEltTy, cast<VectorType>(Args[0]->
getType())->getElementCount());
1978 thisT()->getIntrinsicInstrCost(StepVecAttrs,
CostKind);
1981 thisT()->getArithmeticInstrCost(Instruction::Sub, NewVecTy,
CostKind);
1982 Cost += thisT()->getCastInstrCost(Instruction::SExt, NewVecTy,
1986 thisT()->getArithmeticInstrCost(Instruction::And, NewVecTy,
CostKind);
1989 NewEltTy, NewVecTy, FMF,
I, 1);
1990 Cost += thisT()->getTypeBasedIntrinsicInstrCost(ReducAttrs,
CostKind);
1992 thisT()->getArithmeticInstrCost(Instruction::Sub, NewEltTy,
CostKind);
1996 case Intrinsic::experimental_vector_match:
1997 return thisT()->getTypeBasedIntrinsicInstrCost(ICA,
CostKind);
2005 ScalarizationCost = 0;
2006 if (!
RetTy->isVoidTy())
2008 cast<VectorType>(
RetTy),
2010 ScalarizationCost +=
2016 return thisT()->getTypeBasedIntrinsicInstrCost(Attrs,
CostKind);
2037 unsigned VecTyIndex = 0;
2038 if (IID == Intrinsic::vector_reduce_fadd ||
2039 IID == Intrinsic::vector_reduce_fmul)
2041 assert(Tys.size() > VecTyIndex &&
"Unexpected IntrinsicCostAttributes");
2042 VecOpTy = dyn_cast<VectorType>(Tys[VecTyIndex]);
2051 if (isa<ScalableVectorType>(
RetTy) ||
any_of(Tys, [](
const Type *Ty) {
2052 return isa<ScalableVectorType>(Ty);
2058 SkipScalarizationCost ? ScalarizationCostPassed : 0;
2059 unsigned ScalarCalls = 1;
2061 if (
auto *RetVTy = dyn_cast<VectorType>(
RetTy)) {
2062 if (!SkipScalarizationCost)
2065 ScalarCalls = std::max(ScalarCalls,
2067 ScalarRetTy =
RetTy->getScalarType();
2070 for (
Type *Ty : Tys) {
2071 if (
auto *VTy = dyn_cast<VectorType>(Ty)) {
2072 if (!SkipScalarizationCost)
2075 ScalarCalls = std::max(ScalarCalls,
2081 if (ScalarCalls == 1)
2086 thisT()->getIntrinsicInstrCost(ScalarAttrs,
CostKind);
2088 return ScalarCalls * ScalarCost + ScalarizationCost;
2092 case Intrinsic::sqrt:
2095 case Intrinsic::sin:
2098 case Intrinsic::cos:
2101 case Intrinsic::sincos:
2104 case Intrinsic::sincospi:
2107 case Intrinsic::modf:
2110 case Intrinsic::tan:
2113 case Intrinsic::asin:
2116 case Intrinsic::acos:
2119 case Intrinsic::atan:
2122 case Intrinsic::atan2:
2125 case Intrinsic::sinh:
2128 case Intrinsic::cosh:
2131 case Intrinsic::tanh:
2134 case Intrinsic::exp:
2137 case Intrinsic::exp2:
2140 case Intrinsic::exp10:
2143 case Intrinsic::log:
2146 case Intrinsic::log10:
2149 case Intrinsic::log2:
2152 case Intrinsic::fabs:
2155 case Intrinsic::canonicalize:
2158 case Intrinsic::minnum:
2161 case Intrinsic::maxnum:
2164 case Intrinsic::minimum:
2167 case Intrinsic::maximum:
2170 case Intrinsic::minimumnum:
2173 case Intrinsic::maximumnum:
2176 case Intrinsic::copysign:
2179 case Intrinsic::floor:
2182 case Intrinsic::ceil:
2185 case Intrinsic::trunc:
2188 case Intrinsic::nearbyint:
2191 case Intrinsic::rint:
2194 case Intrinsic::lrint:
2197 case Intrinsic::llrint:
2200 case Intrinsic::round:
2203 case Intrinsic::roundeven:
2206 case Intrinsic::pow:
2209 case Intrinsic::fma:
2212 case Intrinsic::fmuladd:
2215 case Intrinsic::experimental_constrained_fmuladd:
2219 case Intrinsic::lifetime_start:
2220 case Intrinsic::lifetime_end:
2221 case Intrinsic::sideeffect:
2222 case Intrinsic::pseudoprobe:
2223 case Intrinsic::arithmetic_fence:
2225 case Intrinsic::masked_store: {
2227 Align TyAlign = thisT()->DL.getABITypeAlign(Ty);
2228 return thisT()->getMaskedMemoryOpCost(Instruction::Store, Ty, TyAlign, 0,
2231 case Intrinsic::masked_load: {
2233 Align TyAlign = thisT()->DL.getABITypeAlign(Ty);
2234 return thisT()->getMaskedMemoryOpCost(Instruction::Load, Ty, TyAlign, 0,
2237 case Intrinsic::experimental_vp_strided_store: {
2238 auto *Ty = cast<VectorType>(ICA.
getArgTypes()[0]);
2239 Align Alignment = thisT()->DL.getABITypeAlign(Ty->getElementType());
2240 return thisT()->getStridedMemoryOpCost(
2241 Instruction::Store, Ty,
nullptr,
true,
2244 case Intrinsic::experimental_vp_strided_load: {
2246 Align Alignment = thisT()->DL.getABITypeAlign(Ty->getElementType());
2247 return thisT()->getStridedMemoryOpCost(
2248 Instruction::Load, Ty,
nullptr,
true,
2251 case Intrinsic::vector_reduce_add:
2252 case Intrinsic::vector_reduce_mul:
2253 case Intrinsic::vector_reduce_and:
2254 case Intrinsic::vector_reduce_or:
2255 case Intrinsic::vector_reduce_xor:
2256 return thisT()->getArithmeticReductionCost(
2259 case Intrinsic::vector_reduce_fadd:
2260 case Intrinsic::vector_reduce_fmul:
2261 return thisT()->getArithmeticReductionCost(
2263 case Intrinsic::vector_reduce_smax:
2264 case Intrinsic::vector_reduce_smin:
2265 case Intrinsic::vector_reduce_umax:
2266 case Intrinsic::vector_reduce_umin:
2267 case Intrinsic::vector_reduce_fmax:
2268 case Intrinsic::vector_reduce_fmin:
2269 case Intrinsic::vector_reduce_fmaximum:
2270 case Intrinsic::vector_reduce_fminimum:
2273 case Intrinsic::experimental_vector_match: {
2274 auto *SearchTy = cast<VectorType>(ICA.
getArgTypes()[0]);
2275 auto *NeedleTy = cast<FixedVectorType>(ICA.
getArgTypes()[1]);
2276 unsigned SearchSize = NeedleTy->getNumElements();
2281 if (!getTLI()->shouldExpandVectorMatch(SearchVT, SearchSize))
2287 Cost += thisT()->getVectorInstrCost(Instruction::ExtractElement, NeedleTy,
2289 Cost += thisT()->getVectorInstrCost(Instruction::InsertElement, SearchTy,
2293 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, SearchTy,
RetTy,
2296 thisT()->getArithmeticInstrCost(BinaryOperator::Or,
RetTy,
CostKind);
2299 thisT()->getArithmeticInstrCost(BinaryOperator::And,
RetTy,
CostKind);
2302 case Intrinsic::abs:
2305 case Intrinsic::fshl:
2308 case Intrinsic::fshr:
2311 case Intrinsic::smax:
2314 case Intrinsic::smin:
2317 case Intrinsic::umax:
2320 case Intrinsic::umin:
2323 case Intrinsic::sadd_sat:
2326 case Intrinsic::ssub_sat:
2329 case Intrinsic::uadd_sat:
2332 case Intrinsic::usub_sat:
2335 case Intrinsic::smul_fix:
2338 case Intrinsic::umul_fix:
2341 case Intrinsic::sadd_with_overflow:
2344 case Intrinsic::ssub_with_overflow:
2347 case Intrinsic::uadd_with_overflow:
2350 case Intrinsic::usub_with_overflow:
2353 case Intrinsic::smul_with_overflow:
2356 case Intrinsic::umul_with_overflow:
2359 case Intrinsic::fptosi_sat:
2362 case Intrinsic::fptoui_sat:
2365 case Intrinsic::ctpop:
2371 case Intrinsic::ctlz:
2374 case Intrinsic::cttz:
2377 case Intrinsic::bswap:
2380 case Intrinsic::bitreverse:
2383 case Intrinsic::ucmp:
2386 case Intrinsic::scmp:
2391 auto *ST = dyn_cast<StructType>(
RetTy);
2392 Type *LegalizeTy = ST ? ST->getContainedType(0) :
RetTy;
2398 if (IID == Intrinsic::fabs && LT.second.isFloatingPoint() &&
2408 return (LT.first * 2);
2410 return (LT.first * 1);
2414 return (LT.first * 2);
2418 case Intrinsic::fmuladd: {
2422 return thisT()->getArithmeticInstrCost(BinaryOperator::FMul,
RetTy,
2424 thisT()->getArithmeticInstrCost(BinaryOperator::FAdd,
RetTy,
2427 case Intrinsic::experimental_constrained_fmuladd: {
2429 Intrinsic::experimental_constrained_fmul,
RetTy, Tys);
2431 Intrinsic::experimental_constrained_fadd,
RetTy, Tys);
2432 return thisT()->getIntrinsicInstrCost(FMulAttrs,
CostKind) +
2433 thisT()->getIntrinsicInstrCost(FAddAttrs,
CostKind);
2435 case Intrinsic::smin:
2436 case Intrinsic::smax:
2437 case Intrinsic::umin:
2438 case Intrinsic::umax: {
2440 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2441 bool IsUnsigned = IID == Intrinsic::umax || IID == Intrinsic::umin;
2445 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp,
RetTy, CondTy,
2447 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy, CondTy,
2451 case Intrinsic::sadd_with_overflow:
2452 case Intrinsic::ssub_with_overflow: {
2453 Type *SumTy =
RetTy->getContainedType(0);
2454 Type *OverflowTy =
RetTy->getContainedType(1);
2455 unsigned Opcode = IID == Intrinsic::sadd_with_overflow
2456 ? BinaryOperator::Add
2457 : BinaryOperator::Sub;
2464 Cost += thisT()->getArithmeticInstrCost(Opcode, SumTy,
CostKind);
2466 2 * thisT()->getCmpSelInstrCost(Instruction::ICmp, SumTy, OverflowTy,
2468 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::Xor, OverflowTy,
2472 case Intrinsic::uadd_with_overflow:
2473 case Intrinsic::usub_with_overflow: {
2474 Type *SumTy =
RetTy->getContainedType(0);
2475 Type *OverflowTy =
RetTy->getContainedType(1);
2476 unsigned Opcode = IID == Intrinsic::uadd_with_overflow
2477 ? BinaryOperator::Add
2478 : BinaryOperator::Sub;
2484 Cost += thisT()->getArithmeticInstrCost(Opcode, SumTy,
CostKind);
2485 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, SumTy,
2489 case Intrinsic::smul_with_overflow:
2490 case Intrinsic::umul_with_overflow: {
2491 Type *MulTy =
RetTy->getContainedType(0);
2492 Type *OverflowTy =
RetTy->getContainedType(1);
2495 bool IsSigned = IID == Intrinsic::smul_with_overflow;
2497 unsigned ExtOp = IsSigned ? Instruction::SExt : Instruction::ZExt;
2501 Cost += 2 * thisT()->getCastInstrCost(ExtOp, ExtTy, MulTy, CCH,
CostKind);
2503 thisT()->getArithmeticInstrCost(Instruction::Mul, ExtTy,
CostKind);
2504 Cost += 2 * thisT()->getCastInstrCost(Instruction::Trunc, MulTy, ExtTy,
2506 Cost += thisT()->getArithmeticInstrCost(
2511 Cost += thisT()->getArithmeticInstrCost(
2512 Instruction::AShr, MulTy,
CostKind,
2516 Cost += thisT()->getCmpSelInstrCost(
2520 case Intrinsic::sadd_sat:
2521 case Intrinsic::ssub_sat: {
2523 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2527 ? Intrinsic::sadd_with_overflow
2528 : Intrinsic::ssub_with_overflow;
2535 nullptr, ScalarizationCostPassed);
2536 Cost += thisT()->getIntrinsicInstrCost(Attrs,
CostKind);
2537 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp,
RetTy, CondTy,
2539 Cost += 2 * thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy,
2543 case Intrinsic::uadd_sat:
2544 case Intrinsic::usub_sat: {
2545 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2549 ? Intrinsic::uadd_with_overflow
2550 : Intrinsic::usub_with_overflow;
2554 nullptr, ScalarizationCostPassed);
2555 Cost += thisT()->getIntrinsicInstrCost(Attrs,
CostKind);
2557 thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy, CondTy,
2561 case Intrinsic::smul_fix:
2562 case Intrinsic::umul_fix: {
2563 unsigned ExtSize =
RetTy->getScalarSizeInBits() * 2;
2564 Type *ExtTy =
RetTy->getWithNewBitWidth(ExtSize);
2567 IID == Intrinsic::smul_fix ? Instruction::SExt : Instruction::ZExt;
2573 thisT()->getArithmeticInstrCost(Instruction::Mul, ExtTy,
CostKind);
2574 Cost += 2 * thisT()->getCastInstrCost(Instruction::Trunc,
RetTy, ExtTy,
2576 Cost += thisT()->getArithmeticInstrCost(
2579 Cost += thisT()->getArithmeticInstrCost(
2585 case Intrinsic::abs: {
2587 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2590 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp,
RetTy, CondTy,
2592 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy, CondTy,
2595 Cost += thisT()->getArithmeticInstrCost(
2600 case Intrinsic::fshl:
2601 case Intrinsic::fshr: {
2604 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2607 thisT()->getArithmeticInstrCost(BinaryOperator::Or,
RetTy,
CostKind);
2609 thisT()->getArithmeticInstrCost(BinaryOperator::Sub,
RetTy,
CostKind);
2611 thisT()->getArithmeticInstrCost(BinaryOperator::Shl,
RetTy,
CostKind);
2612 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::LShr,
RetTy,
2614 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::URem,
RetTy,
2617 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp,
RetTy, CondTy,
2619 Cost += thisT()->getCmpSelInstrCost(BinaryOperator::Select,
RetTy, CondTy,
2623 case Intrinsic::fptosi_sat:
2624 case Intrinsic::fptoui_sat: {
2627 Type *FromTy = Tys[0];
2628 bool IsSigned = IID == Intrinsic::fptosi_sat;
2633 Cost += thisT()->getIntrinsicInstrCost(Attrs1,
CostKind);
2636 Cost += thisT()->getIntrinsicInstrCost(Attrs2,
CostKind);
2637 Cost += thisT()->getCastInstrCost(
2638 IsSigned ? Instruction::FPToSI : Instruction::FPToUI,
RetTy, FromTy,
2641 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2642 Cost += thisT()->getCmpSelInstrCost(
2644 Cost += thisT()->getCmpSelInstrCost(
2649 case Intrinsic::ucmp:
2650 case Intrinsic::scmp: {
2651 Type *CmpTy = Tys[0];
2652 Type *CondTy =
RetTy->getWithNewBitWidth(1);
2654 thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, CmpTy, CondTy,
2657 thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, CmpTy, CondTy,
2664 Cost += 2 * thisT()->getCmpSelInstrCost(
2665 BinaryOperator::Select,
RetTy, CondTy,
2670 2 * thisT()->getCastInstrCost(CastInst::ZExt,
RetTy, CondTy,
2672 Cost += thisT()->getArithmeticInstrCost(BinaryOperator::Sub,
RetTy,
2684 if (
auto *RetVTy = dyn_cast<VectorType>(
RetTy)) {
2686 if (isa<ScalableVectorType>(
RetTy) ||
any_of(Tys, [](
const Type *Ty) {
2687 return isa<ScalableVectorType>(Ty);
2692 SkipScalarizationCost
2693 ? ScalarizationCostPassed
2697 unsigned ScalarCalls = cast<FixedVectorType>(RetVTy)->getNumElements();
2699 for (
Type *Ty : Tys) {
2706 thisT()->getIntrinsicInstrCost(Attrs,
CostKind);
2707 for (
Type *Ty : Tys) {
2708 if (
auto *VTy = dyn_cast<VectorType>(Ty)) {
2712 ScalarCalls = std::max(ScalarCalls,
2716 return ScalarCalls * ScalarCost + ScalarizationCost;
2720 return SingleCallCost;
2742 if (!LT.first.isValid())
2746 if (
auto *FTp = dyn_cast<FixedVectorType>(Tp);
2747 Tp && LT.second.isFixedLengthVector() &&
2749 if (
auto *SubTp = dyn_cast_if_present<FixedVectorType>(
2752 return divideCeil(FTp->getNumElements(), SubTp->getNumElements());
2754 return *LT.first.getValue();
2787 if (isa<ScalableVectorType>(Ty))
2791 unsigned NumVecElts = cast<FixedVectorType>(Ty)->getNumElements();
2792 if ((Opcode == Instruction::Or || Opcode == Instruction::And) &&
2802 return thisT()->getCastInstrCost(Instruction::BitCast, ValTy, Ty,
2804 thisT()->getCmpSelInstrCost(Instruction::ICmp, ValTy,
2808 unsigned NumReduxLevels =
Log2_32(NumVecElts);
2811 std::pair<InstructionCost, MVT> LT = thisT()->getTypeLegalizationCost(Ty);
2812 unsigned LongVectorCount = 0;
2814 LT.second.isVector() ? LT.second.getVectorNumElements() : 1;
2815 while (NumVecElts > MVTLen) {
2820 ArithCost += thisT()->getArithmeticInstrCost(Opcode, SubTy,
CostKind);
2825 NumReduxLevels -= LongVectorCount;
2837 NumReduxLevels * thisT()->getArithmeticInstrCost(Opcode, Ty,
CostKind);
2838 return ShuffleCost + ArithCost +
2839 thisT()->getVectorInstrCost(Instruction::ExtractElement, Ty,
2863 if (isa<ScalableVectorType>(Ty))
2866 auto *VTy = cast<FixedVectorType>(Ty);
2873 return ExtractCost + ArithCost;
2877 std::optional<FastMathFlags> FMF,
2879 assert(Ty &&
"Unknown reduction vector type");
2892 if (isa<ScalableVectorType>(Ty))
2896 unsigned NumVecElts = cast<FixedVectorType>(Ty)->getNumElements();
2897 unsigned NumReduxLevels =
Log2_32(NumVecElts);
2900 std::pair<InstructionCost, MVT> LT = thisT()->getTypeLegalizationCost(Ty);
2901 unsigned LongVectorCount = 0;
2903 LT.second.isVector() ? LT.second.getVectorNumElements() : 1;
2904 while (NumVecElts > MVTLen) {
2917 NumReduxLevels -= LongVectorCount;
2930 return ShuffleCost + MinMaxCost +
2931 thisT()->getVectorInstrCost(Instruction::ExtractElement, Ty,
2939 if (
auto *FTy = dyn_cast<FixedVectorType>(Ty);
2940 FTy && IsUnsigned && Opcode == Instruction::Add &&
2947 return thisT()->getCastInstrCost(Instruction::BitCast, IntTy, FTy,
2949 thisT()->getIntrinsicInstrCost(ICA,
CostKind);
2955 thisT()->getArithmeticReductionCost(Opcode, ExtTy, FMF,
CostKind);
2957 IsUnsigned ? Instruction::ZExt : Instruction::SExt, ExtTy, Ty,
2960 return RedCost + ExtCost;
2971 Instruction::Add, ExtTy, std::nullopt,
CostKind);
2973 IsUnsigned ? Instruction::ZExt : Instruction::SExt, ExtTy, Ty,
2977 thisT()->getArithmeticInstrCost(Instruction::Mul, ExtTy,
CostKind);
2979 return RedCost + MulCost + 2 * ExtCost;
This file implements a class to represent arbitrary precision integral constant values and operations...
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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")))
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
mir Rename Register Operands
static const Function * getCalledFunction(const Value *V)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static unsigned getNumElements(Type *Ty)
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool sgt(const APInt &RHS) const
Signed greater than comparison.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool slt(const APInt &RHS) const
Signed less than comparison.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
an instruction to allocate memory on the stack
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Base class which can be used to help build a TTI implementation.
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx)
bool isTypeLegal(Type *Ty)
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
Get intrinsic cost based on arguments.
bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const
virtual unsigned getPrefetchDistance() const
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP, OptimizationRemarkEmitter *ORE)
bool preferToKeepConstantsAttached(const Instruction &Inst, const Function &Fn) const
unsigned getMaxInterleaveFactor(ElementCount VF)
unsigned getNumberOfParts(Type *Tp)
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *DataTy, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind)
InstructionCost getExpandCompressMemoryOpCost(unsigned Opcode, Type *DataTy, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index)
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
std::optional< unsigned > getVScaleForTuning() const
InstructionCost getOrderedReductionCost(unsigned Opcode, VectorType *Ty, TTI::TargetCostKind CostKind)
Try to calculate the cost of performing strict (in-order) reductions, which involves doing a sequence...
bool isNumRegsMajorCostOfLSR()
bool isTruncateFree(Type *Ty1, Type *Ty2)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo)
InstructionCost getTreeReductionCost(unsigned Opcode, VectorType *Ty, TTI::TargetCostKind CostKind)
Try to calculate arithmetic and shuffle op costs for reduction intrinsics.
bool preferPredicateOverEpilogue(TailFoldingInfo *TFI)
virtual bool shouldPrefetchAddressSpace(unsigned AS) const
InstructionCost getStridedMemoryOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I)
bool isLegalICmpImmediate(int64_t imm)
bool isProfitableToHoist(Instruction *I)
virtual unsigned getMaxPrefetchIterationsAhead() const
InstructionCost getVectorInstrCost(const Instruction &I, Type *Val, TTI::TargetCostKind CostKind, unsigned Index)
std::optional< unsigned > getMaxVScale() const
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *Ty, int &Index, VectorType *&SubTy) const
InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
unsigned getRegUsageForType(Type *Ty)
bool shouldBuildRelLookupTables() const
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
Try to calculate op costs for min/max reduction operations.
unsigned getCallerAllocaCost(const CallBase *CB, const AllocaInst *AI) 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)
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 getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JumpTableSize, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI)
bool isIndexedLoadLegal(TTI::MemIndexedMode M, Type *Ty, const DataLayout &DL) const
bool shouldDropLSRSolutionIfLessProfitable() const
bool isLSRCostLess(TTI::LSRCost C1, TTI::LSRCost C2)
std::optional< Value * > simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed)
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)
virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
bool hasBranchDivergence(const Function *F=nullptr)
bool isIndexedStoreLegal(TTI::MemIndexedMode M, Type *Ty, const DataLayout &DL) const
unsigned getAssumedAddrSpace(const Value *V) const
InstructionCost getOperandsScalarizationOverhead(ArrayRef< const Value * > Args, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind)
Estimate the overhead of scalarizing an instructions unique non-constant operands.
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *, const SCEV *)
unsigned getEpilogueVectorizationMinVF()
int64_t getPreferredLargeGEPBaseOffset(int64_t MinOffset, int64_t MaxOffset)
InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, Type *AccessType, TTI::TargetCostKind CostKind)
bool isFCmpOrdCheaperThanFCmpZero(Type *Ty)
bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) const
virtual std::optional< unsigned > getCacheSize(TargetTransformInfo::CacheLevel Level) const
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace)
bool isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID, int RetIdx) const
bool isAlwaysUniform(const Value *V)
TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow=true)
bool allowsMisalignedMemoryAccesses(LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace, Align Alignment, unsigned *Fast) const
unsigned getStoreMinimumVF(unsigned VF, Type *ScalarMemTy, Type *ScalarValTy) const
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
InstructionCost getScalarizationOverhead(VectorType *InTy, bool Insert, bool Extract, TTI::TargetCostKind CostKind)
Helper wrapper for the DemandedElts variant of getScalarizationOverhead.
virtual std::optional< unsigned > getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const
virtual bool enableWritePrefetching() const
Value * rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, Value *OldV, Value *NewV) const
void getPeelingPreferences(Loop *L, ScalarEvolution &SE, TTI::PeelingPreferences &PP)
InstructionCost getMulAccReductionCost(bool IsUnsigned, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind)
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool collectFlatAddressOperands(SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const
InstructionCost getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind)
Compute a cost of the given call instruction.
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
InstructionCost getFPOpCost(Type *Ty)
InstructionCost getVectorSplitCost()
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
Estimate the cost of type-legalization and the legalized type.
bool haveFastSqrt(Type *Ty)
std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
unsigned getInliningThresholdMultiplier() const
InstructionCost getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind)
virtual ~BasicTTIImplBase()=default
bool isLegalAddScalableImmediate(int64_t Imm)
InstructionCost getScalarizationOverhead(VectorType *RetTy, ArrayRef< const Value * > Args, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind)
Estimate the overhead of scalarizing the inputs and outputs of an instruction, with return type RetTy...
bool isVScaleKnownToBeAPowerOfTwo() const
std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II)
bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const
bool isLegalAddImmediate(int64_t imm)
bool shouldBuildLookupTables()
unsigned getFlatAddressSpace()
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.
virtual unsigned getCacheLineSize() const
bool isNoopAddrSpaceCast(unsigned FromAS, unsigned ToAS) const
bool isSourceOfDivergence(const Value *V)
bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx) const
int getInlinerVectorBonusPercent() const
InstructionCost getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
Get intrinsic cost based on argument types.
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)
std::optional< Value * > simplifyDemandedVectorEltsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp)
bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace, Instruction *I=nullptr, int64_t ScalableOffset=0)
bool isSingleThreaded() const
BasicTTIImplBase(const TargetMachine *TM, const DataLayout &DL)
bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx) const
unsigned adjustInliningThreshold(const CallBase *CB)
bool isProfitableLSRChainElement(Instruction *I)
Concrete BasicTTIImpl that can be used if no further customization is needed.
size_type count() const
count - Returns the number of bits which are set.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ ICMP_ULT
unsigned less than
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
CmpInst::Predicate getLTPredicate() const
CmpInst::Predicate getGTPredicate() const
This class represents a range of values.
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
unsigned getIndexSizeInBits(unsigned AS) const
Size in bits of index used for address calculation in getelementptr.
constexpr bool isVector() const
One or more elements.
static constexpr ElementCount getFixed(ScalarTy MinVal)
constexpr bool isScalar() const
Exactly one element.
Convenience struct for specifying and reasoning about fast-math flags.
Container class for subtarget features.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
AttributeList getAttributes() const
Return the attribute list for this Function.
The core instruction combiner logic.
static InstructionCost getInvalid(CostType Val=0)
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.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
FastMathFlags getFlags() const
const SmallVectorImpl< Type * > & getArgTypes() const
Type * getReturnType() const
bool skipScalarizationCost() const
const SmallVectorImpl< const Value * > & getArgs() const
InstructionCost getScalarizationCost() const
const IntrinsicInst * getInst() const
Intrinsic::ID getID() const
bool isTypeBasedOnly() const
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Represents a single loop in the control flow graph.
virtual bool shouldPrefetchAddressSpace(unsigned AS) const
virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
Return the minimum stride necessary to trigger software prefetching.
virtual bool enableWritePrefetching() const
virtual unsigned getMaxPrefetchIterationsAhead() const
Return the maximum prefetch distance in terms of loop iterations.
virtual unsigned getPrefetchDistance() const
Return the preferred prefetch distance in terms of instructions.
virtual std::optional< unsigned > getCacheAssociativity(unsigned Level) const
Return the cache associatvity for the given level of cache.
virtual std::optional< unsigned > getCacheLineSize(unsigned Level) const
Return the target cache line size in bytes at a given level.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Analysis providing profile information.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
static bool isZeroEltSplatMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses all elements with the same value as the first element of exa...
static bool isSpliceMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is a splice mask, concatenating the two inputs together and then ext...
static bool isSelectMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from its source vectors without lane crossings.
static bool isExtractSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &Index)
Return true if this shuffle mask is an extract subvector mask.
static bool isReverseMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask swaps the order of elements from exactly one source vector.
static bool isTransposeMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask is a transpose mask.
static bool isInsertSubvectorMask(ArrayRef< int > Mask, int NumSrcElts, int &NumSubElts, int &Index)
Return true if this shuffle mask is an insert subvector mask.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StackOffset holds a fixed and a scalable offset in bytes.
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Provides information about what library functions are available for the current target.
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
bool isOperationExpand(unsigned Op, EVT VT) const
Return true if the specified operation is illegal on this target or unlikely to be made legal with cu...
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
bool isIndexedStoreLegal(unsigned IdxMode, EVT VT) const
Return true if the specified indexed load is legal on this target.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
virtual bool isLegalICmpImmediate(int64_t) const
Return true if the specified immediate is legal icmp immediate, that is the target has icmp instructi...
const TargetMachine & getTargetMachine() const
virtual bool isZExtFree(Type *FromTy, Type *ToTy) const
Return true if any actual instruction that defines a value of type FromTy implicitly zero-extends the...
@ TypeScalarizeScalableVector
virtual bool isSuitableForJumpTable(const SwitchInst *SI, uint64_t NumCases, uint64_t Range, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI) const
Return true if lowering to a jump table is suitable for a set of case clusters which may contain NumC...
virtual bool areJTsAllowed(const Function *Fn) const
Return true if lowering to a jump table is allowed.
bool isOperationLegalOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal using promotion.
virtual unsigned getNumRegisters(LLVMContext &Context, EVT VT, std::optional< MVT > RegisterVT=std::nullopt) const
Return the number of registers that this ValueType will eventually require.
virtual bool isCheapToSpeculateCttz(Type *Ty) const
Return true if it is cheap to speculate a call to intrinsic cttz.
bool isTruncStoreLegal(EVT ValVT, EVT MemVT) const
Return true if the specified store with truncation is legal on this target.
unsigned getBitWidthForCttzElements(Type *RetTy, ElementCount EC, bool ZeroIsPoison, const ConstantRange *VScaleRange) const
Return the minimum number of bits required to hold the maximum possible number of trailing zero vecto...
virtual bool shouldExpandCmpUsingSelects(EVT VT) const
Should we expand [US]CMP nodes using two selects and two compares, or by doing arithmetic on boolean ...
virtual bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace=0, Align Alignment=Align(1), MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *=nullptr) const
Determine if the target supports unaligned memory accesses.
virtual bool isTruncateFree(Type *FromTy, Type *ToTy) const
Return true if it's free to truncate a value of type FromTy to type ToTy.
virtual EVT getTypeToTransformTo(LLVMContext &Context, EVT VT) const
For types supported by the target, this is an identity function.
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
bool isSuitableForBitTests(unsigned NumDests, unsigned NumCmps, const APInt &Low, const APInt &High, const DataLayout &DL) const
Return true if lowering to a bit test is suitable for a set of case clusters which contains NumDests ...
virtual bool isLegalAddImmediate(int64_t) const
Return true if the specified immediate is legal add immediate, that is the target has add instruction...
virtual bool isFreeAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast from SrcAS to DestAS is "cheap", such that e.g.
LegalizeAction getTruncStoreAction(EVT ValVT, EVT MemVT) const
Return how this store with truncation should be treated: either it is legal, needs to be promoted to ...
LegalizeAction getLoadExtAction(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return how this load with extension should be treated: either it is legal, needs to be promoted to a ...
virtual bool isIntDivCheap(EVT VT, AttributeList Attr) const
Return true if integer divide is usually cheaper than a sequence of several shifts,...
bool isOperationLegalOrCustom(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
virtual bool isProfitableToHoist(Instruction *I) const
bool isIndexedLoadLegal(unsigned IdxMode, EVT VT) const
Return true if the specified indexed load is legal on this target.
bool isLoadExtLegal(unsigned ExtType, EVT ValVT, EVT MemVT) const
Return true if the specified load with extension is legal on this target.
virtual bool isCheapToSpeculateCtlz(Type *Ty) const
Return true if it is cheap to speculate a call to intrinsic ctlz.
virtual int64_t getPreferredLargeGEPBaseOffset(int64_t MinOffset, int64_t MaxOffset) const
Return the prefered common base offset.
LegalizeKind getTypeConversion(LLVMContext &Context, EVT VT) const
Return pair that represents the legalization kind (first) that needs to happen to EVT (second) in ord...
LegalizeTypeAction getTypeAction(LLVMContext &Context, EVT VT) const
Return how we should legalize values of this type, either it is already legal (return 'Legal') or we ...
virtual bool isLegalAddScalableImmediate(int64_t) const
Return true if adding the specified scalable immediate is legal, that is the target has add instructi...
bool isBeneficialToExpandPowI(int64_t Exponent, bool OptForSize) const
Return true if it is beneficial to expand an @llvm.powi.
virtual bool isFAbsFree(EVT VT) const
Return true if an fabs operation is free to the point where it is never worthwhile to replace it with...
virtual bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AddrSpace, Instruction *I=nullptr) const
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
bool isOperationLegalOrCustomOrPromote(unsigned Op, EVT VT, bool LegalOnly=false) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
std::pair< LegalizeTypeAction, EVT > LegalizeKind
LegalizeKind holds the legalization kind that needs to happen to EVT in order to type-legalize it.
Primary interface to the complete machine description for the target machine.
virtual std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
If the specified predicate checks whether a generic pointer falls within a specified address space,...
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
virtual unsigned getAssumedAddrSpace(const Value *V) const
If the specified generic pointer could be assumed as a pointer to a specific address space,...
ThreadModel::Model ThreadModel
ThreadModel - This flag specifies the type of threading model to assume for things like atomics.
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual bool useAA() const
Enable use of alias analysis during code generation (during MI scheduling, DAGCombine,...
Triple - Helper class for working with autoconf configuration names.
ArchType getArch() const
Get the parsed architecture type of this triple.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, XROS, or DriverKit).
static constexpr TypeSize getFixed(ScalarTy ExactSize)
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.
static IntegerType * getInt1Ty(LLVMContext &C)
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getWithNewBitWidth(unsigned NewBitWidth) const
Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old numb...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt8Ty(LLVMContext &C)
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Value * getOperand(unsigned i) const
static bool isVPBinOp(Intrinsic::ID ID)
static bool isVPCast(Intrinsic::ID ID)
static bool isVPCmp(Intrinsic::ID ID)
static std::optional< unsigned > getFunctionalOpcodeForVP(Intrinsic::ID ID)
static std::optional< Intrinsic::ID > getFunctionalIntrinsicIDForVP(Intrinsic::ID ID)
static bool isVPIntrinsic(Intrinsic::ID)
static bool isVPReduction(Intrinsic::ID ID)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
Base class of all SIMD vector types.
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Type * getElementType() const
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
APInt ScaleBitMask(const APInt &A, unsigned NewBitWidth, bool MatchAllBits=false)
Splat/Merge neighboring bits to widen/narrow the bitmask represented by.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
@ BSWAP
Byte Swap and Counting operators.
@ SMULFIX
RESULT = [US]MULFIX(LHS, RHS, SCALE) - Perform fixed point multiplication on 2 integers with the same...
@ FMA
FMA - Perform a * b + c with no intermediate rounding step.
@ FMODF
FMODF - Decomposes the operand into integral and fractional parts, each having the same type and sign...
@ FATAN2
FATAN2 - atan2, inspired by libm.
@ FSINCOSPI
FSINCOSPI - Compute both the sine and cosine times pi more accurately than FSINCOS(pi*x),...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ FSINCOS
FSINCOS - Compute both fsin and fcos as a single operation.
@ SSUBO
Same for subtraction.
@ BRIND
BRIND - Indirect branch.
@ BR_JT
BR_JT - Jumptable branch.
@ FCANONICALIZE
Returns platform specific canonical encoding of a floating point number.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
@ SMULO
Same for multiplication.
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ SCMP
[US]CMP - 3-way comparison of signed or unsigned integers.
@ FP_TO_SINT_SAT
FP_TO_[US]INT_SAT - Convert floating point value in operand 0 to a signed or unsigned scalar integer ...
@ FCOPYSIGN
FCOPYSIGN(X, Y) - Return the value of X with the sign of Y.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
@ FMINIMUMNUM
FMINIMUMNUM/FMAXIMUMNUM - minimumnum/maximumnum that is same with FMINNUM_IEEE and FMAXNUM_IEEE besid...
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
ID ArrayRef< Type * > Tys
bool isTargetIntrinsic(ID IID)
isTargetIntrinsic - Returns true if IID is an intrinsic specific to a certain target.
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Intrinsic::ID getMinMaxReductionIntrinsicOp(Intrinsic::ID RdxID)
Returns the min/max intrinsic used when expanding a min/max reduction.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
unsigned getArithmeticReductionInstruction(Intrinsic::ID RdxID)
Returns the arithmetic instruction opcode used when expanding a reduction.
constexpr bool has_single_bit(T Value) noexcept
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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.
ConstantRange getVScaleRange(const Function *F, unsigned BitWidth)
Determine the possible constant range of vscale with the given bit width, based on the vscale_range f...
constexpr int PoisonMaskElem
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
constexpr unsigned BitWidth
cl::opt< unsigned > PartialUnrollingThreshold
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
ElementCount getVectorElementCount() const
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth)
Returns the EVT that represents an integer with the given number of bits.
Type * getTypeForEVT(LLVMContext &Context) const
This method returns an LLVM type corresponding to the specified EVT.
Attributes of a target dependent hardware loop.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...