LLVM: include/llvm/Analysis/TargetTransformInfoImpl.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
15#define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
16
25#include
26#include
27
28namespace llvm {
29
31
32
33
35
36protected:
38
40
42
43public:
45
46
49
51
52
53
56 Type *AccessType,
58
59
60 for (const Value *Operand : Operands)
63
65 }
66
73
74 virtual unsigned
78 (void)PSI;
79 (void)BFI;
80 JTSize = 0;
81 return SI.getNumCases();
82 }
83
89
98
99
100 return 15000;
101 }
109
111
115
117
118
119
120
121
122
123
127
129
133
137
141
145
147
152
154 virtual bool
156 return AS == 0;
157 };
158
160
162
163 virtual std::pair<const Value *, unsigned>
165 return std::make_pair(nullptr, -1);
166 }
167
170 Value *NewV) const {
171 return nullptr;
172 }
173
175 assert(F && "A concrete function must be provided to this routine.");
176
177
178
179
180
181
182 if (F->isIntrinsic())
183 return false;
184
185 if (F->hasLocalLinkage() || ->hasName())
186 return true;
187
189
190
191
192 if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
193 Name == "fabs" || Name == "fabsf" || Name == "fabsl" ||
194 Name == "fmin" || Name == "fminf" || Name == "fminl" ||
195 Name == "fmax" || Name == "fmaxf" || Name == "fmaxl" ||
196 Name == "sin" || Name == "sinf" || Name == "sinl" ||
197 Name == "cos" || Name == "cosf" || Name == "cosl" ||
198 Name == "tan" || Name == "tanf" || Name == "tanl" ||
199 Name == "asin" || Name == "asinf" || Name == "asinl" ||
200 Name == "acos" || Name == "acosf" || Name == "acosl" ||
201 Name == "atan" || Name == "atanf" || Name == "atanl" ||
202 Name == "atan2" || Name == "atan2f" || Name == "atan2l"||
203 Name == "sinh" || Name == "sinhf" || Name == "sinhl" ||
204 Name == "cosh" || Name == "coshf" || Name == "coshl" ||
205 Name == "tanh" || Name == "tanhf" || Name == "tanhl" ||
206 Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ||
207 Name == "exp10" || Name == "exp10l" || Name == "exp10f")
208 return false;
209
210
211 if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
212 Name == "exp2l" || Name == "exp2f" || Name == "floor" ||
213 Name == "floorf" || Name == "ceil" || Name == "round" ||
214 Name == "ffs" || Name == "ffsl" || Name == "abs" || Name == "labs" ||
215 Name == "llabs")
216 return false;
217
218 return true;
219 }
220
227
229
233
238
239 virtual std::optional<Instruction *>
241 return std::nullopt;
242 }
243
244 virtual std::optional<Value *>
247 bool &KnownBitsComputed) const {
248 return std::nullopt;
249 }
250
253 APInt &UndefElts2, APInt &UndefElts3,
255 SimplifyAndSetOp) const {
256 return std::nullopt;
257 }
258
262
265
267
269
271
273 int64_t BaseOffset, bool HasBaseReg,
274 int64_t Scale, unsigned AddrSpace,
276 int64_t ScalableOffset = 0) const {
277
278
279 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
280 }
281
289
291
293
297
299
305
310
316
322
324
325
326 unsigned DataSize = DL.getTypeStoreSize(DataType);
328 }
329
331
332
333 unsigned DataSize = DL.getTypeStoreSize(DataType);
335 }
336
341
345
349
351 Align Alignment) const {
352 return false;
353 }
354
356 Align Alignment) const {
357 return false;
358 }
359
361 Align Alignment) const {
362 return false;
363 }
364
366 unsigned Opcode1,
368 return false;
369 }
370
374
378
381 unsigned AddrSpace) const {
382 return false;
383 }
384
386 Type *DataType) const {
387 return false;
388 }
389
391
395
399
401
404 bool HasBaseReg, int64_t Scale,
405 unsigned AddrSpace) const {
406
408 Scale, AddrSpace, nullptr,
410 return 0;
412 }
413
415
417
419
420 virtual bool useAA() const { return false; }
421
423
425
427
431
433
435
437
441
443 unsigned ScalarOpdIdx) const {
444 return false;
445 }
446
448 int OpdIdx) const {
449 return OpdIdx == -1;
450 }
451
452 virtual bool
454 int RetIdx) const {
455 return RetIdx == 0;
456 }
457
459 VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
462 return 0;
463 }
464
470
472
474
478
482
487
489
491
492
495 return false;
496
497
501 }
502
504
508
510
515 unsigned *Fast) const {
516 return false;
517 }
518
523
525
529
531
535
537 const APInt &Imm,
538 Type *Ty) const {
539 return 0;
540 }
541
546
553
559
564
569
571 Type *Ty = nullptr) const {
572 return Vector ? 1 : 0;
573 }
574
576 switch (ClassID) {
577 default:
578 return "Generic::Unknown Register Class";
579 case 0:
580 return "Generic::ScalarRC";
581 case 1:
582 return "Generic::VectorRC";
583 }
584 }
585
590
592
593 virtual std::optional getMaxVScale() const { return std::nullopt; }
595 return std::nullopt;
596 }
598
599 virtual bool
603
607
608 virtual unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const {
609 return 0;
610 }
614
616 const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
617 AllowPromotionWithoutCommonHeader = false;
618 return false;
619 }
620
622 virtual std::optional
624 switch (Level) {
626 [[fallthrough]];
628 return std::nullopt;
629 }
631 }
632
633 virtual std::optional
635 switch (Level) {
637 [[fallthrough]];
639 return std::nullopt;
640 }
641
643 }
644
645 virtual std::optional getMinPageSize() const { return {}; }
646
649 unsigned NumStridedMemAccesses,
650 unsigned NumPrefetches,
651 bool HasCall) const {
652 return 1;
653 }
657
659 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
664 }
665
667
672
673
674 auto IsWidenableCondition = [](const Value *V) {
676 if (II->getIntrinsicID() == Intrinsic::experimental_widenable_condition)
677 return true;
678 return false;
679 };
680
681
682 switch (Opcode) {
683 default:
684 break;
685 case Instruction::FDiv:
686 case Instruction::FRem:
687 case Instruction::SDiv:
688 case Instruction::SRem:
689 case Instruction::UDiv:
690 case Instruction::URem:
691
693 case Instruction::And:
694 case Instruction::Or:
695 if (any_of(Args, IsWidenableCondition))
697 break;
698 }
699
700
702 if (Ty->getScalarType()->isFloatingPointTy())
703 return 3;
704
705 return 1;
706 }
707
709 unsigned Opcode1,
713 }
714
719 const Instruction *CxtI = nullptr) const {
720 return 1;
721 }
722
727 switch (Opcode) {
728 default:
729 break;
730 case Instruction::IntToPtr: {
731 unsigned SrcSize = Src->getScalarSizeInBits();
732 if (DL.isLegalInteger(SrcSize) &&
733 SrcSize <= DL.getPointerTypeSizeInBits(Dst))
734 return 0;
735 break;
736 }
737 case Instruction::PtrToAddr: {
738 unsigned DstSize = Dst->getScalarSizeInBits();
739 assert(DstSize == DL.getAddressSizeInBits(Src));
740 if (DL.isLegalInteger(DstSize))
741 return 0;
742 break;
743 }
744 case Instruction::PtrToInt: {
745 unsigned DstSize = Dst->getScalarSizeInBits();
746 if (DL.isLegalInteger(DstSize) &&
747 DstSize >= DL.getPointerTypeSizeInBits(Src))
748 return 0;
749 break;
750 }
751 case Instruction::BitCast:
752 if (Dst == Src || (Dst->isPointerTy() && Src->isPointerTy()))
753
754 return 0;
755 break;
756 case Instruction::Trunc: {
757
758
759 TypeSize DstSize = DL.getTypeSizeInBits(Dst);
761 return 0;
762 break;
763 }
764 }
765 return 1;
766 }
767
773
777
778
780 return 0;
781 return 1;
782 }
783
790
793 unsigned Index, const Value *Op0,
794 const Value *Op1) const {
795 return 1;
796 }
797
798
799
800
801
805 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx) const {
806 return 1;
807 }
808
811 unsigned Index) const {
812 return 1;
813 }
814
818 unsigned Index) const {
819 return 1;
820 }
821
824 const APInt &DemandedDstElts,
826 return 1;
827 }
828
832
833
834
835 if (Opcode == Instruction::InsertValue &&
839 }
840
847
851 bool UseMaskForCond, bool UseMaskForGaps) const {
852 return 1;
853 }
854
858 switch (ICA.getID()) {
859 default:
860 break;
861 case Intrinsic::allow_runtime_check:
862 case Intrinsic::allow_ubsan_check:
863 case Intrinsic::annotation:
864 case Intrinsic::assume:
865 case Intrinsic::sideeffect:
866 case Intrinsic::pseudoprobe:
867 case Intrinsic::arithmetic_fence:
868 case Intrinsic::dbg_assign:
869 case Intrinsic::dbg_declare:
870 case Intrinsic::dbg_value:
871 case Intrinsic::dbg_label:
872 case Intrinsic::invariant_start:
873 case Intrinsic::invariant_end:
874 case Intrinsic::launder_invariant_group:
875 case Intrinsic::strip_invariant_group:
876 case Intrinsic::is_constant:
877 case Intrinsic::lifetime_start:
878 case Intrinsic::lifetime_end:
879 case Intrinsic::experimental_noalias_scope_decl:
880 case Intrinsic::objectsize:
881 case Intrinsic::ptr_annotation:
882 case Intrinsic::var_annotation:
883 case Intrinsic::experimental_gc_result:
884 case Intrinsic::experimental_gc_relocate:
885 case Intrinsic::coro_alloc:
886 case Intrinsic::coro_begin:
887 case Intrinsic::coro_begin_custom_abi:
888 case Intrinsic::coro_free:
889 case Intrinsic::coro_end:
890 case Intrinsic::coro_frame:
891 case Intrinsic::coro_size:
892 case Intrinsic::coro_align:
893 case Intrinsic::coro_suspend:
894 case Intrinsic::coro_subfn_addr:
895 case Intrinsic::threadlocal_address:
896 case Intrinsic::experimental_widenable_condition:
897 case Intrinsic::ssa_copy:
898
899 return 0;
900 }
901 return 1;
902 }
903
907 switch (MICA.getID()) {
908 case Intrinsic::masked_scatter:
909 case Intrinsic::masked_gather:
910 case Intrinsic::masked_load:
911 case Intrinsic::masked_store:
912 case Intrinsic::vp_scatter:
913 case Intrinsic::vp_gather:
914 case Intrinsic::masked_compressstore:
915 case Intrinsic::masked_expandload:
916 return 1;
917 }
919 }
920
926
927
929
932 const SCEV *,
934 return 0;
935 }
936
939 std::optional FMF,
941 return 1;
942 }
943
949
952 VectorType *Ty, std::optional FMF,
954 return 1;
955 }
956
962
967
972
974
975
976
977
978
979 return 0;
980 }
981
984 bool CanCreate = true) const {
985 return nullptr;
986 }
987
988 virtual Type *
990 unsigned SrcAddrSpace, unsigned DestAddrSpace,
992 std::optional<uint32_t> AtomicElementSize) const {
993 return AtomicElementSize ? Type::getIntNTy(Context, *AtomicElementSize * 8)
995 }
996
999 unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace,
1001 std::optional<uint32_t> AtomicCpySize) const {
1002 unsigned OpSizeInBytes = AtomicCpySize.value_or(1);
1004 for (unsigned i = 0; i != RemainingBytes; i += OpSizeInBytes)
1006 }
1007
1009 const Function *Callee) const {
1010 return (Caller->getFnAttribute("target-cpu") ==
1011 Callee->getFnAttribute("target-cpu")) &&
1012 (Caller->getFnAttribute("target-features") ==
1013 Callee->getFnAttribute("target-features"));
1014 }
1015
1017 unsigned DefaultCallPenalty) const {
1018 return DefaultCallPenalty;
1019 }
1020
1024 return (Caller->getFnAttribute("target-cpu") ==
1025 Callee->getFnAttribute("target-cpu")) &&
1026 (Caller->getFnAttribute("target-features") ==
1027 Callee->getFnAttribute("target-features"));
1028 }
1029
1031 return false;
1032 }
1033
1035 return false;
1036 }
1037
1041
1043
1045
1047 Align Alignment,
1048 unsigned AddrSpace) const {
1049 return true;
1050 }
1051
1053 Align Alignment,
1054 unsigned AddrSpace) const {
1055 return true;
1056 }
1057
1062
1066
1068 unsigned ChainSizeInBytes,
1070 return VF;
1071 }
1072
1074 unsigned ChainSizeInBytes,
1076 return VF;
1077 }
1078
1080 return false;
1081 }
1082
1084 return false;
1085 }
1087
1089
1091
1093
1097
1102
1104
1106
1108
1110
1112
1115 return false;
1116 }
1117
1119
1126
1128
1132
1136
1138 return false;
1139 }
1140
1142
1147
1151
1153
1154protected:
1155
1156
1160
1161
1162
1164
1165
1167
1168
1169 unsigned MaxRequiredSize =
1170 VT->getElementType()->getPrimitiveSizeInBits().getFixedValue();
1171
1172 unsigned MinRequiredSize = 0;
1173 for (unsigned i = 0, e = VT->getNumElements(); i < e; ++i) {
1174 if (auto *IntElement =
1176 bool signedElement = IntElement->getValue().isNegative();
1177
1178 unsigned ElementMinRequiredSize =
1179 IntElement->getValue().getSignificantBits() - 1;
1180
1182
1183 MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
1184 } else {
1185
1186 return MaxRequiredSize;
1187 }
1188 }
1189 return MinRequiredSize;
1190 }
1191
1193 isSigned = CI->getValue().isNegative();
1194 return CI->getValue().getSignificantBits() - 1;
1195 }
1196
1199 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
1200 }
1201
1204 return Cast->getSrcTy()->getScalarSizeInBits();
1205 }
1206
1209 }
1210
1214
1216 const SCEV *Ptr) const {
1218 return nullptr;
1221 }
1222
1224 int64_t MergeDistance) const {
1226 if (!Step)
1227 return false;
1230 return false;
1231
1232 return StrideVal.getSExtValue() < MergeDistance;
1233 }
1234};
1235
1236
1237
1238template
1240private:
1242
1243protected:
1245
1246public:
1250 assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
1252 bool HasBaseReg = (BaseGV == nullptr);
1253
1254 auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
1255 APInt BaseOffset(PtrSizeBits, 0);
1256 int64_t Scale = 0;
1257
1259 Type *TargetType = nullptr;
1260
1261
1262
1263 if (Operands.empty())
1265
1266 for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) {
1267 TargetType = GTI.getIndexedType();
1268
1269
1271 if (!ConstIdx)
1274 if (StructType *STy = GTI.getStructTypeOrNull()) {
1275
1276 assert(ConstIdx && "Unexpected GEP index");
1278 BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
1279 } else {
1280
1281
1284 int64_t ElementSize =
1285 GTI.getSequentialElementStride(DL).getFixedValue();
1286 if (ConstIdx) {
1287 BaseOffset +=
1289 } else {
1290
1291 if (Scale != 0)
1292
1294 Scale = ElementSize;
1295 }
1296 }
1297 }
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308 if (!AccessType)
1309 AccessType = TargetType;
1310
1311
1312
1314 AccessType, const_cast<GlobalValue *>(BaseGV),
1318
1319
1320
1321
1323 }
1324
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340 for (const Value *V : Ptrs) {
1342 if ()
1343 continue;
1344 if (Info.isSameBase() && V != Base) {
1345 if (GEP->hasAllConstantIndices())
1346 continue;
1348 Instruction::Add, GEP->getType(), CostKind,
1349 {TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None},
1350 {});
1351 } else {
1354 GEP->getSourceElementType(), GEP->getPointerOperand(), Indices,
1356 }
1357 }
1358 return Cost;
1359 }
1360
1365
1366 auto *TargetTTI = static_cast<const T *>(this);
1367
1368
1371 if (const Function *F = CB->getCalledFunction()) {
1372 if (!TargetTTI->isLoweredToCall(F))
1373 return TTI::TCC_Basic;
1374
1375 return TTI::TCC_Basic * (F->getFunctionType()->getNumParams() + 1);
1376 }
1377
1379 }
1380
1381 Type *Ty = U->getType();
1384 switch (Opcode) {
1385 default:
1386 break;
1387 case Instruction::Call: {
1391 return TargetTTI->getIntrinsicInstrCost(CostAttrs, CostKind);
1392 }
1393 case Instruction::Br:
1394 case Instruction::Ret:
1395 case Instruction::PHI:
1396 case Instruction::Switch:
1397 return TargetTTI->getCFInstrCost(Opcode, CostKind, I);
1398 case Instruction::Freeze:
1400 case Instruction::ExtractValue:
1401 case Instruction::InsertValue:
1402 return TargetTTI->getInsertExtractValueCost(Opcode, CostKind);
1403 case Instruction::Alloca:
1406 break;
1407 case Instruction::GetElementPtr: {
1409 Type *AccessType = nullptr;
1410
1411
1412 if (GEP->hasOneUser() && I)
1413 AccessType = I->user_back()->getAccessType();
1414
1415 return TargetTTI->getGEPCost(GEP->getSourceElementType(),
1418 }
1419 case Instruction::Add:
1420 case Instruction::FAdd:
1421 case Instruction::Sub:
1422 case Instruction::FSub:
1423 case Instruction::Mul:
1424 case Instruction::FMul:
1425 case Instruction::UDiv:
1426 case Instruction::SDiv:
1427 case Instruction::FDiv:
1428 case Instruction::URem:
1429 case Instruction::SRem:
1430 case Instruction::FRem:
1431 case Instruction::Shl:
1432 case Instruction::LShr:
1433 case Instruction::AShr:
1434 case Instruction::And:
1435 case Instruction::Or:
1436 case Instruction::Xor:
1437 case Instruction::FNeg: {
1440 if (Opcode != Instruction::FNeg)
1442 return TargetTTI->getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
1443 Op2Info, Operands, I);
1444 }
1445 case Instruction::IntToPtr:
1446 case Instruction::PtrToAddr:
1447 case Instruction::PtrToInt:
1448 case Instruction::SIToFP:
1449 case Instruction::UIToFP:
1450 case Instruction::FPToUI:
1451 case Instruction::FPToSI:
1452 case Instruction::Trunc:
1453 case Instruction::FPTrunc:
1454 case Instruction::BitCast:
1455 case Instruction::FPExt:
1456 case Instruction::SExt:
1457 case Instruction::ZExt:
1458 case Instruction::AddrSpaceCast: {
1459 Type *OpTy = Operands[0]->getType();
1460 return TargetTTI->getCastInstrCost(
1462 }
1463 case Instruction::Store: {
1465 Type *ValTy = Operands[0]->getType();
1467 return TargetTTI->getMemoryOpCost(Opcode, ValTy, SI->getAlign(),
1468 SI->getPointerAddressSpace(), CostKind,
1469 OpInfo, I);
1470 }
1471 case Instruction::Load: {
1472
1474 return 4;
1476 Type *LoadType = U->getType();
1477
1478
1479
1480
1481
1482
1483
1487 LoadType = TI->getDestTy();
1488 }
1489 return TargetTTI->getMemoryOpCost(Opcode, LoadType, LI->getAlign(),
1491 {TTI::OK_AnyValue, TTI::OP_None}, I);
1492 }
1493 case Instruction::Select: {
1494 const Value *Op0, *Op1;
1497
1498
1503
1505 return TargetTTI->getArithmeticInstrCost(
1506 match(U, m_LogicalOr()) ? Instruction::Or : Instruction::And, Ty,
1507 CostKind, Op1Info, Op2Info, Operands, I);
1508 }
1511 Type *CondTy = Operands[0]->getType();
1512 return TargetTTI->getCmpSelInstrCost(Opcode, U->getType(), CondTy,
1515 }
1516 case Instruction::ICmp:
1517 case Instruction::FCmp: {
1520 Type *ValTy = Operands[0]->getType();
1521
1522 return TargetTTI->getCmpSelInstrCost(Opcode, ValTy, U->getType(),
1526 }
1527 case Instruction::InsertElement: {
1529 if (!IE)
1531 unsigned Idx = -1;
1533 if (CI->getValue().getActiveBits() <= 32)
1534 Idx = CI->getZExtValue();
1535 return TargetTTI->getVectorInstrCost(*IE, Ty, CostKind, Idx);
1536 }
1537 case Instruction::ShuffleVector: {
1539 if (!Shuffle)
1541
1545 int NumSubElts, SubIndex;
1546
1547
1548 if (all_of(Mask, [](int M) { return M < 0; }))
1550
1551
1552 if (Shuffle->changesLength()) {
1553
1554 if (Shuffle->increasesLength() && Shuffle->isIdentityWithPadding())
1556
1557 if (Shuffle->isExtractSubvectorMask(SubIndex))
1559 VecSrcTy, Mask, CostKind, SubIndex,
1560 VecTy, Operands, Shuffle);
1561
1562 if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
1563 return TargetTTI->getShuffleCost(
1565 SubIndex,
1567 Operands, Shuffle);
1568
1569 int ReplicationFactor, VF;
1570 if (Shuffle->isReplicationMask(ReplicationFactor, VF)) {
1574 DemandedDstElts.setBit(I.index());
1575 }
1576 return TargetTTI->getReplicationShuffleCost(
1577 VecSrcTy->getElementType(), ReplicationFactor, VF,
1579 }
1580
1582 NumSubElts = VecSrcTy->getElementCount().getKnownMinValue();
1584
1585
1586
1587
1588 if (Shuffle->increasesLength()) {
1589 for (int &M : AdjustMask)
1590 M = M >= NumSubElts ? (M + (Mask.size() - NumSubElts)) : M;
1591
1592 return TargetTTI->getShuffleCost(
1594 VecTy, AdjustMask, CostKind, 0, nullptr, Operands, Shuffle);
1595 }
1596
1597
1598
1599
1600
1602
1603 InstructionCost ShuffleCost = TargetTTI->getShuffleCost(
1605 VecSrcTy, VecSrcTy, AdjustMask, CostKind, 0, nullptr, Operands,
1606 Shuffle);
1607
1609 std::iota(ExtractMask.begin(), ExtractMask.end(), 0);
1610 return ShuffleCost + TargetTTI->getShuffleCost(
1612 ExtractMask, CostKind, 0, VecTy, {}, Shuffle);
1613 }
1614
1615 if (Shuffle->isIdentity())
1617
1618 if (Shuffle->isReverse())
1619 return TargetTTI->getShuffleCost(TTI::SK_Reverse, VecTy, VecSrcTy, Mask,
1620 CostKind, 0, nullptr, Operands,
1621 Shuffle);
1622
1623 if (Shuffle->isTranspose())
1624 return TargetTTI->getShuffleCost(TTI::SK_Transpose, VecTy, VecSrcTy,
1625 Mask, CostKind, 0, nullptr, Operands,
1626 Shuffle);
1627
1628 if (Shuffle->isZeroEltSplat())
1629 return TargetTTI->getShuffleCost(TTI::SK_Broadcast, VecTy, VecSrcTy,
1630 Mask, CostKind, 0, nullptr, Operands,
1631 Shuffle);
1632
1633 if (Shuffle->isSingleSource())
1635 VecSrcTy, Mask, CostKind, 0, nullptr,
1636 Operands, Shuffle);
1637
1638 if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
1639 return TargetTTI->getShuffleCost(
1642 Shuffle);
1643
1644 if (Shuffle->isSelect())
1645 return TargetTTI->getShuffleCost(TTI::SK_Select, VecTy, VecSrcTy, Mask,
1646 CostKind, 0, nullptr, Operands,
1647 Shuffle);
1648
1649 if (Shuffle->isSplice(SubIndex))
1650 return TargetTTI->getShuffleCost(TTI::SK_Splice, VecTy, VecSrcTy, Mask,
1651 CostKind, SubIndex, nullptr, Operands,
1652 Shuffle);
1653
1655 Mask, CostKind, 0, nullptr, Operands,
1656 Shuffle);
1657 }
1658 case Instruction::ExtractElement: {
1660 if (!EEI)
1662 unsigned Idx = -1;
1664 if (CI->getValue().getActiveBits() <= 32)
1665 Idx = CI->getZExtValue();
1666 Type *DstTy = Operands[0]->getType();
1667 return TargetTTI->getVectorInstrCost(*EEI, DstTy, CostKind, Idx);
1668 }
1669 }
1670
1671
1673 }
1674
1676 auto *TargetTTI = static_cast<const T *>(this);
1681 }
1682
1686};
1687}
1688
1689#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Analysis containing CSE Info
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static bool isSigned(unsigned int Opcode)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
uint64_t IntrinsicInst * II
OptimizedStructLayoutField Field
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
static SymbolRef::Type getType(const Symbol *Sym)
This pass exposes codegen information to IR-level passes.
Class for arbitrary precision integers.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
unsigned getBitWidth() const
Return the number of bits in the APInt.
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
int64_t getSExtValue() const
Get sign extended value.
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.
const T & front() const
front - Get the first element.
bool empty() const
empty - Check if the array is empty.
Class to represent array types.
A cache of @llvm.assume calls within a function.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Conditional or Unconditional Branch instruction.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
This is the shared class of boolean and integer constants.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const APInt & getValue() const
Return the constant as an APInt value reference.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Convenience struct for specifying and reasoning about fast-math flags.
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
The core instruction combiner logic.
static InstructionCost getInvalid(CostType Val=0)
Intrinsic::ID getID() const
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
Represents a single loop in the control flow graph.
Information for memory intrinsic cost model.
Intrinsic::ID getID() const
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Analysis providing profile information.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
This node represents a polynomial recurrence on the trip count of the specified loop.
const SCEV * getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
This class represents a constant integer value.
const APInt & getAPInt() const
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
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)
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
Class to represent struct types.
Provides information about what library functions are available for the current target.
virtual InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:68
virtual bool preferAlternateOpcodeVectorization() const
Definition TargetTransformInfoImpl.h:1086
virtual bool isProfitableLSRChainElement(Instruction *I) const
Definition TargetTransformInfoImpl.h:294
virtual unsigned getCallerAllocaCost(const CallBase *CB, const AllocaInst *AI) const
Definition TargetTransformInfoImpl.h:105
virtual bool shouldBuildLookupTables() const
Definition TargetTransformInfoImpl.h:426
virtual int getInliningLastCallToStaticBonus() const
Definition TargetTransformInfoImpl.h:97
virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const
Definition TargetTransformInfoImpl.h:968
virtual InstructionCost getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const
Definition TargetTransformInfoImpl.h:964
virtual unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const
Definition TargetTransformInfoImpl.h:608
virtual InstructionCost getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:958
virtual const DataLayout & getDataLayout() const
Definition TargetTransformInfoImpl.h:50
virtual bool preferFixedOverScalableIfEqualCost(bool IsEpilogue) const
Definition TargetTransformInfoImpl.h:1079
virtual std::optional< unsigned > getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const
Definition TargetTransformInfoImpl.h:634
virtual InstructionCost getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:921
virtual bool enableInterleavedAccessVectorization() const
Definition TargetTransformInfoImpl.h:503
virtual InstructionCost getFPOpCost(Type *Ty) const
Definition TargetTransformInfoImpl.h:532
virtual unsigned getMaxInterleaveFactor(ElementCount VF) const
Definition TargetTransformInfoImpl.h:666
virtual bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:371
virtual TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
Definition TargetTransformInfoImpl.h:484
virtual bool supportsTailCalls() const
Definition TargetTransformInfoImpl.h:473
virtual bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:1046
bool isStridedAccess(const SCEV *Ptr) const
Definition TargetTransformInfoImpl.h:1211
virtual ~TargetTransformInfoImplBase()
virtual unsigned getAtomicMemIntrinsicMaxElementSize() const
Definition TargetTransformInfoImpl.h:973
virtual Value * rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, Value *OldV, Value *NewV) const
Definition TargetTransformInfoImpl.h:168
virtual bool supportsScalableVectors() const
Definition TargetTransformInfoImpl.h:1107
virtual TargetTransformInfo::VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const
Definition TargetTransformInfoImpl.h:1121
virtual bool enableAggressiveInterleaving(bool LoopHasReductions) const
Definition TargetTransformInfoImpl.h:479
virtual std::optional< Value * > simplifyDemandedVectorEltsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts, APInt &UndefElts2, APInt &UndefElts3, std::function< void(Instruction *, unsigned, APInt, APInt &)> SimplifyAndSetOp) const
Definition TargetTransformInfoImpl.h:251
virtual bool isLegalMaskedStore(Type *DataType, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind) const
Definition TargetTransformInfoImpl.h:311
virtual InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *, const SCEV *, TTI::TargetCostKind) const
Definition TargetTransformInfoImpl.h:930
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1) const
Definition TargetTransformInfoImpl.h:791
virtual bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const
Definition TargetTransformInfoImpl.h:337
virtual bool isSingleThreaded() const
Definition TargetTransformInfoImpl.h:161
virtual bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty) const
Definition TargetTransformInfoImpl.h:1030
virtual unsigned adjustInliningThreshold(const CallBase *CB) const
Definition TargetTransformInfoImpl.h:102
virtual InstructionCost getPartialReductionCost(unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType, ElementCount VF, TTI::PartialReductionExtendKind OpAExtend, TTI::PartialReductionExtendKind OpBExtend, std::optional< unsigned > BinOp, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:658
virtual unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
Definition TargetTransformInfoImpl.h:1067
virtual bool shouldDropLSRSolutionIfLessProfitable() const
Definition TargetTransformInfoImpl.h:292
virtual bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:396
virtual bool canMacroFuseCmp() const
Definition TargetTransformInfoImpl.h:298
virtual int getInlinerVectorBonusPercent() const
Definition TargetTransformInfoImpl.h:110
virtual bool prefersVectorizedAddressing() const
Definition TargetTransformInfoImpl.h:400
virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind) const
Definition TargetTransformInfoImpl.h:317
virtual bool hasDivRemOp(Type *DataType, bool IsSigned) const
Definition TargetTransformInfoImpl.h:392
virtual bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:375
virtual unsigned getStoreMinimumVF(unsigned VF, Type *, Type *) const
Definition TargetTransformInfoImpl.h:611
virtual bool isLegalICmpImmediate(int64_t Imm) const
Definition TargetTransformInfoImpl.h:270
virtual bool LSRWithInstrQueries() const
Definition TargetTransformInfoImpl.h:414
virtual bool preferPredicatedReductionSelect() const
Definition TargetTransformInfoImpl.h:1088
virtual InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo, const Instruction *I) const
Definition TargetTransformInfoImpl.h:842
virtual bool useAA() const
Definition TargetTransformInfoImpl.h:420
virtual bool preferPredicateOverEpilogue(TailFoldingInfo *TFI) const
Definition TargetTransformInfoImpl.h:230
virtual bool haveFastSqrt(Type *Ty) const
Definition TargetTransformInfoImpl.h:524
virtual ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const
Definition TargetTransformInfoImpl.h:604
virtual bool collectFlatAddressOperands(SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const
Definition TargetTransformInfoImpl.h:148
virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const
Definition TargetTransformInfoImpl.h:142
virtual bool canSaveCmp(Loop *L, BranchInst **BI, ScalarEvolution *SE, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, TargetLibraryInfo *LibInfo) const
Definition TargetTransformInfoImpl.h:300
virtual InstructionCost getVectorInstrCost(const Instruction &I, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const
Definition TargetTransformInfoImpl.h:809
virtual unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const
Definition TargetTransformInfoImpl.h:570
virtual std::optional< unsigned > getVScaleForTuning() const
Definition TargetTransformInfoImpl.h:594
virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:542
virtual InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:402
virtual unsigned getNumberOfParts(Type *Tp) const
Definition TargetTransformInfoImpl.h:928
virtual bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:360
virtual bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const
Definition TargetTransformInfoImpl.h:221
virtual void getPeelingPreferences(Loop *, ScalarEvolution &, TTI::PeelingPreferences &) const
Definition TargetTransformInfoImpl.h:263
virtual std::optional< Value * > simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed) const
Definition TargetTransformInfoImpl.h:245
virtual bool useColdCCForColdCall(Function &F) const
Definition TargetTransformInfoImpl.h:434
virtual unsigned getNumberOfRegisters(unsigned ClassID) const
Definition TargetTransformInfoImpl.h:565
virtual unsigned getPrefetchDistance() const
Definition TargetTransformInfoImpl.h:647
virtual bool canHaveNonUndefGlobalInitializerInAddressSpace(unsigned AS) const
Definition TargetTransformInfoImpl.h:155
virtual bool isLegalAddScalableImmediate(int64_t Imm) const
Definition TargetTransformInfoImpl.h:268
virtual bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:379
TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg)
Definition TargetTransformInfoImpl.h:48
virtual bool shouldPrefetchAddressSpace(unsigned AS) const
Definition TargetTransformInfoImpl.h:656
virtual bool forceScalarizeMaskedScatter(VectorType *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:355
virtual uint64_t getMaxMemIntrinsicInlineSizeThreshold() const
Definition TargetTransformInfoImpl.h:116
virtual unsigned getMinVectorRegisterBitWidth() const
Definition TargetTransformInfoImpl.h:591
unsigned minRequiredElementSize(const Value *Val, bool &isSigned) const
Definition TargetTransformInfoImpl.h:1157
virtual bool shouldBuildLookupTablesForConstant(Constant *C) const
Definition TargetTransformInfoImpl.h:428
virtual bool isFPVectorizationPotentiallyUnsafe() const
Definition TargetTransformInfoImpl.h:509
virtual bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc, ElementCount VF) const
Definition TargetTransformInfoImpl.h:1058
virtual InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const
Definition TargetTransformInfoImpl.h:547
virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const
Definition TargetTransformInfoImpl.h:365
virtual InstructionCost getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const
Definition TargetTransformInfoImpl.h:816
virtual std::optional< unsigned > getCacheSize(TargetTransformInfo::CacheLevel Level) const
Definition TargetTransformInfoImpl.h:623
virtual InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:769
virtual bool shouldTreatInstructionLikeSelect(const Instruction *I) const
Definition TargetTransformInfoImpl.h:490
virtual std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const
Definition TargetTransformInfoImpl.h:240
virtual unsigned getEpilogueVectorizationMinVF() const
Definition TargetTransformInfoImpl.h:228
virtual std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
Definition TargetTransformInfoImpl.h:164
virtual bool shouldMaximizeVectorBandwidth(TargetTransformInfo::RegisterKind K) const
Definition TargetTransformInfoImpl.h:600
virtual void getMemcpyLoopResidualLoweringType(SmallVectorImpl< Type * > &OpsOut, LLVMContext &Context, unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicCpySize) const
Definition TargetTransformInfoImpl.h:997
virtual TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const
Definition TargetTransformInfoImpl.h:520
virtual TTI::AddressingModeKind getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const
Definition TargetTransformInfoImpl.h:307
virtual bool forceScalarizeMaskedGather(VectorType *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:350
virtual unsigned getMaxPrefetchIterationsAhead() const
Definition TargetTransformInfoImpl.h:654
virtual bool allowVectorElementIndexingUsingGEP() const
Definition TargetTransformInfoImpl.h:1152
virtual InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:85
virtual TTI::ReductionShuffle getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const
Definition TargetTransformInfoImpl.h:1099
const SCEVConstant * getConstantStrideStep(ScalarEvolution *SE, const SCEV *Ptr) const
Definition TargetTransformInfoImpl.h:1215
virtual bool hasBranchDivergence(const Function *F=nullptr) const
Definition TargetTransformInfoImpl.h:130
virtual InstructionCost getArithmeticReductionCost(unsigned, VectorType *, std::optional< FastMathFlags > FMF, TTI::TargetCostKind) const
Definition TargetTransformInfoImpl.h:938
virtual bool isProfitableToHoist(Instruction *I) const
Definition TargetTransformInfoImpl.h:418
virtual const char * getRegisterClassName(unsigned ClassID) const
Definition TargetTransformInfoImpl.h:575
virtual InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *, FastMathFlags, TTI::TargetCostKind) const
Definition TargetTransformInfoImpl.h:944
virtual unsigned getCacheLineSize() const
Definition TargetTransformInfoImpl.h:621
virtual bool isLegalToVectorizeLoad(LoadInst *LI) const
Definition TargetTransformInfoImpl.h:1042
virtual bool isTargetIntrinsicTriviallyScalarizable(Intrinsic::ID ID) const
Definition TargetTransformInfoImpl.h:438
virtual unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:1038
virtual InstructionCost getAltInstrCost(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:708
virtual unsigned getInlineCallPenalty(const Function *F, const CallBase &Call, unsigned DefaultCallPenalty) const
Definition TargetTransformInfoImpl.h:1016
virtual bool hasArmWideBranch(bool) const
Definition TargetTransformInfoImpl.h:1127
virtual bool isVectorShiftByScalarCheap(Type *Ty) const
Definition TargetTransformInfoImpl.h:1118
virtual bool isLegalNTStore(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:323
virtual APInt getFeatureMask(const Function &F) const
Definition TargetTransformInfoImpl.h:1129
virtual InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:905
virtual std::optional< unsigned > getMinPageSize() const
Definition TargetTransformInfoImpl.h:645
virtual unsigned getRegUsageForType(Type *Ty) const
Definition TargetTransformInfoImpl.h:424
virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace, Instruction *I=nullptr, int64_t ScalableOffset=0) const
Definition TargetTransformInfoImpl.h:272
virtual bool isElementTypeLegalForScalableVector(Type *Ty) const
Definition TargetTransformInfoImpl.h:1063
virtual bool isLoweredToCall(const Function *F) const
Definition TargetTransformInfoImpl.h:174
virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:342
virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const
Definition TargetTransformInfoImpl.h:416
virtual InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info, TTI::OperandValueInfo Opd2Info, ArrayRef< const Value * > Args, const Instruction *CxtI=nullptr) const
Definition TargetTransformInfoImpl.h:668
virtual bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty) const
Definition TargetTransformInfoImpl.h:1034
virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, Type *AccessType, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:54
virtual BranchProbability getPredictableBranchThreshold() const
Definition TargetTransformInfoImpl.h:124
virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const
Definition TargetTransformInfoImpl.h:138
virtual InstructionCost getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:823
virtual bool enableScalableVectorization() const
Definition TargetTransformInfoImpl.h:1109
virtual bool isLegalToVectorizeStore(StoreInst *SI) const
Definition TargetTransformInfoImpl.h:1044
virtual bool areInlineCompatible(const Function *Caller, const Function *Callee) const
Definition TargetTransformInfoImpl.h:1008
virtual bool isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID, int RetIdx) const
Definition TargetTransformInfoImpl.h:453
virtual bool hasConditionalLoadStoreForType(Type *Ty, bool IsStore) const
Definition TargetTransformInfoImpl.h:566
virtual bool preferInLoopReduction(RecurKind Kind, Type *Ty) const
Definition TargetTransformInfoImpl.h:1083
virtual bool isMultiversionedFunction(const Function &F) const
Definition TargetTransformInfoImpl.h:1137
virtual InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const
Definition TargetTransformInfoImpl.h:774
virtual bool isNoopAddrSpaceCast(unsigned, unsigned) const
Definition TargetTransformInfoImpl.h:153
virtual InstructionUniformity getInstructionUniformity(const Value *V) const
Definition TargetTransformInfoImpl.h:134
virtual bool isVScaleKnownToBeAPowerOfTwo() const
Definition TargetTransformInfoImpl.h:597
virtual bool isExpensiveToSpeculativelyExecute(const Instruction *I) const
Definition TargetTransformInfoImpl.h:526
virtual bool isLSRCostLess(const TTI::LSRCost &C1, const TTI::LSRCost &C2) const
Definition TargetTransformInfoImpl.h:282
virtual bool isLegalMaskedVectorHistogram(Type *AddrType, Type *DataType) const
Definition TargetTransformInfoImpl.h:385
virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:346
virtual unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JTSize, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI) const
Definition TargetTransformInfoImpl.h:75
virtual bool hasActiveVectorLength() const
Definition TargetTransformInfoImpl.h:1111
virtual bool isLegalAddImmediate(int64_t Imm) const
Definition TargetTransformInfoImpl.h:266
virtual InstructionCost getInsertExtractValueCost(unsigned Opcode, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:830
virtual InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I) const
Definition TargetTransformInfoImpl.h:723
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) const
Definition TargetTransformInfoImpl.h:330
virtual InstructionCost getBranchMispredictPenalty() const
Definition TargetTransformInfoImpl.h:128
virtual bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx) const
Definition TargetTransformInfoImpl.h:447
virtual InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:555
TargetTransformInfo TTI
Definition TargetTransformInfoImpl.h:37
virtual InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty) const
Definition TargetTransformInfoImpl.h:536
bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr, int64_t MergeDistance) const
Definition TargetTransformInfoImpl.h:1223
virtual bool enableOrderedReductions() const
Definition TargetTransformInfoImpl.h:390
virtual Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType, bool CanCreate=true) const
Definition TargetTransformInfoImpl.h:983
virtual bool enableMaskedInterleavedAccessVectorization() const
Definition TargetTransformInfoImpl.h:505
virtual Type * getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicElementSize) const
Definition TargetTransformInfoImpl.h:989
virtual unsigned getInliningThresholdMultiplier() const
Definition TargetTransformInfoImpl.h:90
TargetTransformInfoImplBase(const DataLayout &DL)
Definition TargetTransformInfoImpl.h:41
virtual InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:856
virtual InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info, TTI::OperandValueInfo Op2Info, const Instruction *I) const
Definition TargetTransformInfoImpl.h:784
virtual bool shouldExpandReduction(const IntrinsicInst *II) const
Definition TargetTransformInfoImpl.h:1094
virtual bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
Definition TargetTransformInfoImpl.h:1052
virtual unsigned getGISelRematGlobalCost() const
Definition TargetTransformInfoImpl.h:1103
virtual InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond, bool UseMaskForGaps) const
Definition TargetTransformInfoImpl.h:848
virtual bool isTypeLegal(Type *Ty) const
Definition TargetTransformInfoImpl.h:422
virtual bool enableSelectOptimize() const
Definition TargetTransformInfoImpl.h:488
virtual unsigned getAssumedAddrSpace(const Value *V) const
Definition TargetTransformInfoImpl.h:159
virtual bool allowsMisalignedMemoryAccesses(LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace, Align Alignment, unsigned *Fast) const
Definition TargetTransformInfoImpl.h:511
virtual bool enableWritePrefetching() const
Definition TargetTransformInfoImpl.h:655
virtual unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
Definition TargetTransformInfoImpl.h:1073
virtual InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:951
virtual unsigned getInliningCostBenefitAnalysisSavingsMultiplier() const
Definition TargetTransformInfoImpl.h:91
virtual bool areTypesABICompatible(const Function *Caller, const Function *Callee, ArrayRef< Type * > Types) const
Definition TargetTransformInfoImpl.h:1021
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx) const
Definition TargetTransformInfoImpl.h:802
virtual unsigned getMaxNumArgs() const
Definition TargetTransformInfoImpl.h:1141
virtual unsigned getNumBytesToPadGlobalArray(unsigned Size, Type *ArrayType) const
Definition TargetTransformInfoImpl.h:1143
virtual bool preferToKeepConstantsAttached(const Instruction &Inst, const Function &Fn) const
Definition TargetTransformInfoImpl.h:560
virtual InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CxtI=nullptr) const
Definition TargetTransformInfoImpl.h:716
virtual bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const
Definition TargetTransformInfoImpl.h:530
virtual bool supportsTailCallFor(const CallBase *CB) const
Definition TargetTransformInfoImpl.h:475
virtual std::optional< unsigned > getMaxVScale() const
Definition TargetTransformInfoImpl.h:593
virtual bool shouldBuildRelLookupTables() const
Definition TargetTransformInfoImpl.h:432
virtual bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const
Definition TargetTransformInfoImpl.h:615
virtual InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}) const
Definition TargetTransformInfoImpl.h:458
virtual unsigned getFlatAddressSpace() const
Definition TargetTransformInfoImpl.h:146
virtual bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx) const
Definition TargetTransformInfoImpl.h:442
virtual bool shouldConsiderVectorizationRegPressure() const
Definition TargetTransformInfoImpl.h:1092
const DataLayout & DL
Definition TargetTransformInfoImpl.h:39
virtual InstructionCost getMemcpyCost(const Instruction *I) const
Definition TargetTransformInfoImpl.h:112
virtual unsigned getInliningCostBenefitAnalysisProfitableMultiplier() const
Definition TargetTransformInfoImpl.h:94
virtual bool useFastCCForInternalCall(Function &F) const
Definition TargetTransformInfoImpl.h:436
virtual bool isNumRegsMajorCostOfLSR() const
Definition TargetTransformInfoImpl.h:290
virtual InstructionCost getOperandsScalarizationOverhead(ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind) const
Definition TargetTransformInfoImpl.h:466
virtual TailFoldingStyle getPreferredTailFoldingStyle(bool IVUpdateMayOverflow=true) const
Definition TargetTransformInfoImpl.h:235
virtual void getUnrollingPreferences(Loop *, ScalarEvolution &, TTI::UnrollingPreferences &, OptimizationRemarkEmitter *) const
Definition TargetTransformInfoImpl.h:259
TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)=default
virtual bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const
Definition TargetTransformInfoImpl.h:1113
virtual bool supportsEfficientVectorElementLoadStore() const
Definition TargetTransformInfoImpl.h:471
virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
Definition TargetTransformInfoImpl.h:648
virtual APInt getPriorityMask(const Function &F) const
Definition TargetTransformInfoImpl.h:1133
virtual unsigned getMinTripCountTailFoldingThreshold() const
Definition TargetTransformInfoImpl.h:1105
virtual TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
Definition TargetTransformInfoImpl.h:587
virtual void collectKernelLaunchBounds(const Function &F, SmallVectorImpl< std::pair< StringRef, int64_t > > &LB) const
Definition TargetTransformInfoImpl.h:1148
virtual bool preferEpilogueVectorization() const
Definition TargetTransformInfoImpl.h:1090
bool supportsTailCallFor(const CallBase *CB) const override
Definition TargetTransformInfoImpl.h:1683
TargetTransformInfoImplCRTPBase(const DataLayout &DL)
Definition TargetTransformInfoImpl.h:1244
bool isExpensiveToSpeculativelyExecute(const Instruction *I) const override
Definition TargetTransformInfoImpl.h:1675
InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind) const override
Definition TargetTransformInfoImpl.h:1362
InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, TTI::TargetCostKind CostKind) const override
Definition TargetTransformInfoImpl.h:1326
InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, Type *AccessType, TTI::TargetCostKind CostKind) const override
Definition TargetTransformInfoImpl.h:1247
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
static LLVM_ABI CastContextHint getCastContextHint(const Instruction *I)
Calculates a CastContextHint from I.
MaskKind
Some targets only support masked load/store with a constant mask.
static LLVM_ABI OperandValueInfo getOperandInfo(const Value *V)
Collect properties of V used in cost analysis, e.g. OP_PowerOf2.
TargetCostKind
The kind of cost model.
@ TCK_RecipThroughput
Reciprocal throughput.
@ TCK_CodeSize
Instruction code size.
@ TCK_SizeAndLatency
The weighted sum of size and latency.
@ TCK_Latency
The latency of instruction.
PopcntSupportKind
Flags indicating the kind of support for population count.
PartialReductionExtendKind
@ TCC_Expensive
The cost of a 'div' instruction on x86.
@ TCC_Free
Expected to fold away in lowering.
@ TCC_Basic
The cost of a typical 'add' instruction.
MemIndexedMode
The type of load/store indexing.
AddressingModeKind
Which addressing mode Loop Strength Reduction will try to generate.
@ AMK_None
Don't prefer any addressing mode.
ShuffleKind
The various kinds of shuffle patterns for vector queries.
@ SK_InsertSubvector
InsertSubvector. Index indicates start offset.
@ SK_Select
Selects elements from the corresponding lane of either source operand.
@ SK_PermuteSingleSrc
Shuffle elements of single source vector with any shuffle mask.
@ SK_Transpose
Transpose two vectors.
@ SK_Splice
Concatenates elements from the first input vector with elements of the second input vector.
@ SK_Broadcast
Broadcast element 0 to all other elements.
@ SK_PermuteTwoSrc
Merge elements from two source vectors into one with any shuffle mask.
@ SK_Reverse
Reverse the order of the vector.
@ SK_ExtractSubvector
ExtractSubvector Index indicates start offset.
CastContextHint
Represents a hint about the context in which a cast is used.
CacheLevel
The possible cache levels.
This class represents a truncation of integer types.
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.
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
This is the common base class for vector predication intrinsics.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Fast
Attempts to make calls as fast as possible (e.g.
@ C
The default llvm calling convention, compatible with C.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
class_match< Constant > m_Constant()
Match an arbitrary Constant and ignore it.
bool match(Val *V, const Pattern &P)
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
match_combine_or< LTy, RTy > m_CombineOr(const LTy &L, const RTy &R)
Combine two pattern matchers matching L || R.
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.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t DataSize
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr int PoisonMaskElem
RecurKind
These are the kinds of recurrences that we support.
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
gep_type_iterator gep_type_begin(const User *GEP)
@ DataWithoutLaneMask
Same as Data, but avoids using the get.active.lane.mask intrinsic to calculate the mask and instead i...
InstructionUniformity
Enum describing how instructions behave with respect to uniformity and divergence,...
@ Default
The result values are uniform if and only if all operands are uniform.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Attributes of a target dependent hardware loop.
Information about a load/store intrinsic defined by the target.
Returns options for expansion of memcmp. IsZeroCmp is.
Describe known properties for a set of pointers.
Parameters that control the generic loop unrolling transformation.