LLVM 24.0.0git
TargetTransformInfoImpl.h
Go to the documentation of this file.
1//===- TargetTransformInfoImpl.h --------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file provides helpers for the implementation of
10/// a TargetTransformInfo-conforming class.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
15#define LLVM_ANALYSIS_TARGETTRANSFORMINFOIMPL_H
16
21#include "llvm/IR/DataLayout.h"
24#include "llvm/IR/Operator.h"
26#include <optional>
27#include <utility>
28
29namespace llvm {
30
31class Function;
32
33/// Base class for use as a mix-in that aids implementing
34/// a TargetTransformInfo-compatible class.
36
37protected:
39
40 const DataLayout &DL;
41
43
44public:
46
47 // Provide value semantics. MSVC requires that we spell all of these out.
50
51 virtual const DataLayout &getDataLayout() const { return DL; }
52
53 // FIXME: It looks like this implementation is dead. All clients appear to
54 // use the (non-const) version from `TargetTransformInfoImplCRTPBase`.
55 virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
58 Type *AccessType) const {
59 // In the basic model, we just assume that all-constant GEPs will be folded
60 // into their uses via addressing modes.
61 for (const Value *Operand : Operands)
62 if (!isa<Constant>(Operand))
63 return TTI::TCC_Basic;
64
65 return TTI::TCC_Free;
66 }
67
68 virtual InstructionCost
70 const TTI::PointersChainInfo &Info, Type *AccessTy,
71 const TTI::TargetCostKind CostKind) const {
72 llvm_unreachable("Not implemented");
73 }
74
75 virtual unsigned
78 BlockFrequencyInfo *BFI) const {
79 (void)PSI;
80 (void)BFI;
81 JTSize = 0;
82 return SI.getNumCases();
83 }
84
85 virtual InstructionCost
90
91 virtual unsigned getInliningThresholdMultiplier() const { return 1; }
93 return 8;
94 }
96 return 8;
97 }
99 // This is the value of InlineConstants::LastCallToStaticBonus before it was
100 // removed along with the introduction of this function.
101 return 15000;
102 }
103 virtual unsigned adjustInliningThreshold(const CallBase *CB) const {
104 return 0;
105 }
106 virtual unsigned getCallerAllocaCost(const CallBase *CB,
107 const AllocaInst *AI) const {
108 return 0;
109 };
110
111 virtual int getInlinerVectorBonusPercent() const { return 150; }
112
114 return TTI::TCC_Expensive;
115 }
116
117 virtual uint64_t getMaxMemIntrinsicInlineSizeThreshold() const { return 64; }
118
119 // Although this default value is arbitrary, it is not random. It is assumed
120 // that a condition that evaluates the same way by a higher percentage than
121 // this is best represented as control flow. Therefore, the default value N
122 // should be set such that the win from N% correct executions is greater than
123 // the loss from (100 - N)% mispredicted executions for the majority of
124 // intended targets.
126 return BranchProbability(99, 100);
127 }
128
129 virtual InstructionCost getBranchMispredictPenalty() const { return 0; }
130
131 virtual bool hasBranchDivergence(const Function *F = nullptr) const {
132 return false;
133 }
134
135 virtual ValueUniformity getValueUniformity(const Value *V) const {
137 }
138
139 virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const {
140 return false;
141 }
142
143 virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const {
144 return true;
145 }
146
147 virtual unsigned getFlatAddressSpace() const { return -1; }
148
149 virtual unsigned getAddressSpaceJoin(unsigned AS1, unsigned AS2) const {
150 return getFlatAddressSpace();
151 }
152
154 Intrinsic::ID IID) const {
155 return false;
156 }
157
158 virtual bool isNoopAddrSpaceCast(unsigned, unsigned) const { return false; }
159
160 virtual std::pair<KnownBits, KnownBits>
161 computeKnownBitsAddrSpaceCast(unsigned ToAS, const Value &PtrOp) const {
162 const Type *PtrTy = PtrOp.getType();
163 assert(PtrTy->isPtrOrPtrVectorTy() &&
164 "expected pointer or pointer vector type");
165 unsigned FromAS = PtrTy->getPointerAddressSpace();
166
167 if (DL.isNonIntegralAddressSpace(FromAS))
168 return std::pair(KnownBits(DL.getPointerSizeInBits(FromAS)),
169 KnownBits(DL.getPointerSizeInBits(ToAS)));
170
171 KnownBits FromPtrBits;
172 if (const AddrSpaceCastInst *CastI = dyn_cast<AddrSpaceCastInst>(&PtrOp)) {
173 std::pair<KnownBits, KnownBits> KB = computeKnownBitsAddrSpaceCast(
174 CastI->getDestAddressSpace(), *CastI->getPointerOperand());
175 FromPtrBits = KB.second;
176 } else {
177 FromPtrBits = computeKnownBits(&PtrOp, DL, nullptr);
178 }
179
180 KnownBits ToPtrBits =
181 computeKnownBitsAddrSpaceCast(FromAS, ToAS, FromPtrBits);
182
183 return {FromPtrBits, ToPtrBits};
184 }
185
186 virtual KnownBits
187 computeKnownBitsAddrSpaceCast(unsigned FromAS, unsigned ToAS,
188 const KnownBits &FromPtrBits) const {
189 unsigned ToASBitSize = DL.getPointerSizeInBits(ToAS);
190
191 if (DL.isNonIntegralAddressSpace(FromAS))
192 return KnownBits(ToASBitSize);
193
194 // By default, we assume that all valid "larger" (e.g. 64-bit) to "smaller"
195 // (e.g. 32-bit) casts work by chopping off the high bits.
196 // By default, we do not assume that null results in null again.
197 return FromPtrBits.anyextOrTrunc(ToASBitSize);
198 }
199
201 unsigned DstAS) const {
202 return {DL.getPointerSizeInBits(SrcAS), 0};
203 }
204
205 virtual bool
207 return AS == 0;
208 };
209
210 virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
211
212 virtual std::pair<const Value *, unsigned>
214 return std::make_pair(nullptr, -1);
215 }
216
218 Value *OldV,
219 Value *NewV) const {
220 return nullptr;
221 }
222
223 virtual bool isLoweredToCall(const Function *F) const {
224 assert(F && "A concrete function must be provided to this routine.");
225
226 // FIXME: These should almost certainly not be handled here, and instead
227 // handled with the help of TLI or the target itself. This was largely
228 // ported from existing analysis heuristics here so that such refactorings
229 // can take place in the future.
230
231 if (F->isIntrinsic())
232 return false;
233
234 if (F->hasLocalLinkage() || !F->hasName())
235 return true;
236
237 StringRef Name = F->getName();
238
239 // These will all likely lower to a single selection DAG node.
240 // clang-format off
241 if (Name == "copysign" || Name == "copysignf" || Name == "copysignl" ||
242 Name == "fabs" || Name == "fabsf" || Name == "fabsl" ||
243 Name == "fmin" || Name == "fminf" || Name == "fminl" ||
244 Name == "fmax" || Name == "fmaxf" || Name == "fmaxl" ||
245 Name == "sin" || Name == "sinf" || Name == "sinl" ||
246 Name == "cos" || Name == "cosf" || Name == "cosl" ||
247 Name == "tan" || Name == "tanf" || Name == "tanl" ||
248 Name == "asin" || Name == "asinf" || Name == "asinl" ||
249 Name == "acos" || Name == "acosf" || Name == "acosl" ||
250 Name == "atan" || Name == "atanf" || Name == "atanl" ||
251 Name == "atan2" || Name == "atan2f" || Name == "atan2l"||
252 Name == "sinh" || Name == "sinhf" || Name == "sinhl" ||
253 Name == "cosh" || Name == "coshf" || Name == "coshl" ||
254 Name == "tanh" || Name == "tanhf" || Name == "tanhl" ||
255 Name == "sqrt" || Name == "sqrtf" || Name == "sqrtl" ||
256 Name == "exp10" || Name == "exp10l" || Name == "exp10f")
257 return false;
258 // clang-format on
259 // These are all likely to be optimized into something smaller.
260 if (Name == "pow" || Name == "powf" || Name == "powl" || Name == "exp2" ||
261 Name == "exp2l" || Name == "exp2f" || Name == "floor" ||
262 Name == "floorf" || Name == "ceil" || Name == "round" ||
263 Name == "ffs" || Name == "ffsl" || Name == "abs" || Name == "labs" ||
264 Name == "llabs")
265 return false;
266
267 return true;
268 }
269
271 AssumptionCache &AC,
272 TargetLibraryInfo *LibInfo,
273 HardwareLoopInfo &HWLoopInfo) const {
274 return false;
275 }
276
277 virtual unsigned getEpilogueVectorizationMinVF() const { return 16; }
278
280 return false;
281 }
282
286
287 virtual std::optional<Instruction *>
289 return std::nullopt;
290 }
291
292 virtual std::optional<Value *>
294 APInt DemandedMask, KnownBits &Known,
295 bool &KnownBitsComputed) const {
296 return std::nullopt;
297 }
298
299 virtual std::optional<Value *> simplifyDemandedVectorEltsIntrinsic(
300 InstCombiner &IC, IntrinsicInst &II, APInt DemandedElts, APInt &UndefElts,
301 APInt &UndefElts2, APInt &UndefElts3,
302 std::function<void(Instruction *, unsigned, APInt, APInt &)>
303 SimplifyAndSetOp) const {
304 return std::nullopt;
305 }
306
310
313
314 virtual bool isLegalAddImmediate(int64_t Imm) const { return false; }
315
316 virtual bool isLegalAddScalableImmediate(int64_t Imm) const { return false; }
317
318 virtual bool isLegalICmpImmediate(int64_t Imm) const { return false; }
319
320 virtual bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV,
321 int64_t BaseOffset, bool HasBaseReg,
322 int64_t Scale, unsigned AddrSpace,
323 Instruction *I = nullptr,
324 int64_t ScalableOffset = 0) const {
325 // Guess that only reg and reg+reg addressing is allowed. This heuristic is
326 // taken from the implementation of LSR.
327 return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
328 }
329
330 virtual bool isLSRCostLess(const TTI::LSRCost &C1,
331 const TTI::LSRCost &C2) const {
332 return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
333 C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
334 std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
335 C2.ScaleCost, C2.ImmCost, C2.SetupCost);
336 }
337
338 virtual bool isNumRegsMajorCostOfLSR() const { return true; }
339
340 virtual bool shouldDropLSRSolutionIfLessProfitable() const { return false; }
341
343 return false;
344 }
345
346 virtual bool canMacroFuseCmp() const { return false; }
347
348 virtual bool canSaveCmp(Loop *L, CondBrInst **BI, ScalarEvolution *SE,
350 TargetLibraryInfo *LibInfo) const {
351 return false;
352 }
353
356 return TTI::AMK_None;
357 }
358
359 virtual bool isLegalMaskedStore(Type *DataType, Align Alignment,
360 unsigned AddressSpace,
361 TTI::MaskKind MaskKind) const {
362 return false;
363 }
364
365 virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment,
366 unsigned AddressSpace,
367 TTI::MaskKind MaskKind) const {
368 return false;
369 }
370
371 virtual bool isLegalSpeculativeLoad(Type *DataType,
372 unsigned AddressSpace) const {
373 return false;
374 }
375
376 virtual bool isLegalNTStore(Type *DataType, Align Alignment) const {
377 // By default, assume nontemporal memory stores are available for stores
378 // that are aligned and have a size that is a power of 2.
379 unsigned DataSize = DL.getTypeStoreSize(DataType);
380 return Alignment >= DataSize && isPowerOf2_32(DataSize);
381 }
382
383 virtual bool isLegalNTLoad(Type *DataType, Align Alignment) const {
384 // By default, assume nontemporal memory loads are available for loads that
385 // are aligned and have a size that is a power of 2.
386 unsigned DataSize = DL.getTypeStoreSize(DataType);
387 return Alignment >= DataSize && isPowerOf2_32(DataSize);
388 }
389
390 virtual bool isLegalBroadcastLoad(Type *ElementTy,
391 ElementCount NumElements) const {
392 return false;
393 }
394
395 virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) const {
396 return false;
397 }
398
399 virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) const {
400 return false;
401 }
402
404 Align Alignment) const {
405 return false;
406 }
407
409 Align Alignment) const {
410 return false;
411 }
412
413 virtual bool isLegalMaskedCompressStore(Type *DataType,
414 Align Alignment) const {
415 return false;
416 }
417
418 virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0,
419 unsigned Opcode1,
420 const SmallBitVector &OpcodeMask,
421 ArrayRef<const Value *> Scalars) const {
422 return false;
423 }
424
425 virtual bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const {
426 return false;
427 }
428
429 virtual bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const {
430 return false;
431 }
432
433 virtual bool
434 hasMultiVectorLoadStore(unsigned NumVectors, TTI::MaskSource Mask,
435 VectorType *VectorTy, bool IsStore,
436 std::optional<Instruction::CastOps> CastHint) const {
437 return false;
438 }
439
440 virtual bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor,
441 Align Alignment,
442 unsigned AddrSpace) const {
443 return false;
444 }
445
446 virtual bool isLegalMaskedVectorHistogram(Type *AddrType,
447 Type *DataType) const {
448 return false;
449 }
450
451 virtual bool enableOrderedReductions() const { return false; }
452
453 virtual bool hasDivRemOp(Type *DataType, bool IsSigned) const {
454 return false;
455 }
456
457 virtual bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) const {
458 return false;
459 }
460
461 virtual bool prefersVectorizedAddressing() const { return true; }
462
464 StackOffset BaseOffset,
465 bool HasBaseReg, int64_t Scale,
466 unsigned AddrSpace) const {
467 // Guess that all legal addressing mode are free.
468 if (isLegalAddressingMode(Ty, BaseGV, BaseOffset.getFixed(), HasBaseReg,
469 Scale, AddrSpace, /*I=*/nullptr,
470 BaseOffset.getScalable()))
471 return 0;
473 }
474
475 virtual bool LSRWithInstrQueries() const { return false; }
476
477 virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const { return false; }
478
479 virtual bool isProfitableToHoist(Instruction *I) const { return true; }
480
481 virtual bool useAA() const { return false; }
482
483 virtual bool isTypeLegal(Type *Ty) const { return false; }
484
485 virtual unsigned getRegUsageForType(Type *Ty) const { return 1; }
486
487 virtual bool shouldBuildLookupTables() const { return true; }
488
490 return true;
491 }
492
493 virtual unsigned getMinimumLookupTableEntryBitWidth() const { return 8; }
494
495 virtual bool shouldBuildRelLookupTables() const { return false; }
496
497 virtual bool useColdCCForColdCall(Function &F) const { return false; }
498
499 virtual bool useFastCCForInternalCall(Function &F) const { return true; }
500
502 unsigned ScalarOpdIdx) const {
503 return false;
504 }
505
507 int OpdIdx) const {
508 return OpdIdx == -1;
509 }
510
511 virtual bool
513 int RetIdx) const {
514 return RetIdx == 0;
515 }
516
518 VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract,
519 TTI::TargetCostKind CostKind, bool ForPoisonSrc = true,
520 ArrayRef<Value *> VL = {},
522 // Default implementation returns 0.
523 // BasicTTIImpl provides the actual implementation.
524 return 0;
525 }
526
532
533 virtual bool supportsEfficientVectorElementLoadStore() const { return false; }
534
535 virtual bool supportsTailCalls() const { return true; }
536
537 virtual bool supportsTailCallFor(const CallBase *CB) const {
538 llvm_unreachable("Not implemented");
539 }
540
541 virtual bool enableAggressiveInterleaving(bool LoopHasReductions) const {
542 return false;
543 }
544
546 enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
547 return {};
548 }
549
550 virtual bool enableSelectOptimize() const { return true; }
551
552 virtual bool shouldTreatInstructionLikeSelect(const Instruction *I) const {
553 // A select with two constant operands will usually be better left as a
554 // select.
555 using namespace llvm::PatternMatch;
557 return false;
558 // If the select is a logical-and/logical-or then it is better treated as a
559 // and/or by the backend.
560 return isa<SelectInst>(I) &&
563 }
564
565 virtual bool enableInterleavedAccessVectorization() const { return false; }
566
568 return false;
569 }
570
571 virtual bool isFPVectorizationPotentiallyUnsafe() const { return false; }
572
574 unsigned BitWidth,
575 unsigned AddressSpace,
576 Align Alignment,
577 unsigned *Fast) const {
578 return false;
579 }
580
582 getPopcntSupport(unsigned IntTyWidthInBit) const {
583 return TTI::PSK_Software;
584 }
585
586 virtual bool haveFastSqrt(Type *Ty) const { return false; }
587
589 return true;
590 }
591
592 virtual bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const { return true; }
593
594 virtual InstructionCost getFPOpCost(Type *Ty) const {
596 }
597
598 virtual InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx,
599 const APInt &Imm,
600 Type *Ty) const {
601 return 0;
602 }
603
606 return TTI::TCC_Basic;
607 }
608
609 virtual InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx,
610 const APInt &Imm, Type *Ty,
612 Instruction *Inst = nullptr) const {
613 return TTI::TCC_Free;
614 }
615
616 virtual InstructionCost
617 getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm,
618 Type *Ty, TTI::TargetCostKind CostKind) const {
619 return TTI::TCC_Free;
620 }
621
623 const Function &Fn) const {
624 return false;
625 }
626
627 virtual unsigned getNumberOfRegisters(unsigned ClassID) const { return 8; }
628 virtual bool hasConditionalLoadStoreForType(Type *Ty, bool IsStore) const {
629 return false;
630 }
631
632 virtual unsigned getRegisterClassForType(bool Vector,
633 Type *Ty = nullptr) const {
634 return Vector ? 1 : 0;
635 }
636
637 virtual const char *getRegisterClassName(unsigned ClassID) const {
638 switch (ClassID) {
639 default:
640 return "Generic::Unknown Register Class";
641 case 0:
642 return "Generic::ScalarRC";
643 case 1:
644 return "Generic::VectorRC";
645 }
646 }
647
648 virtual InstructionCost
651 return TTI::TCC_Basic;
652 }
653
654 virtual InstructionCost
657 return TTI::TCC_Basic;
658 }
659
660 virtual TypeSize
664
665 virtual unsigned getMinVectorRegisterBitWidth() const { return 128; }
666
667 virtual std::optional<unsigned> getVScaleForTuning() const {
668 return std::nullopt;
669 }
670
671 virtual bool
675
676 virtual ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const {
677 return ElementCount::get(0, IsScalable);
678 }
679
680 virtual unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const {
681 return 0;
682 }
683 virtual unsigned getStoreMinimumVF(unsigned VF, Type *, Type *, Align,
684 unsigned) const {
685 return VF;
686 }
687
689 const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const {
690 AllowPromotionWithoutCommonHeader = false;
691 return false;
692 }
693
694 virtual unsigned getCacheLineSize() const { return 0; }
695 virtual std::optional<unsigned>
697 switch (Level) {
699 [[fallthrough]];
701 return std::nullopt;
702 }
703 llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
704 }
705
706 virtual std::optional<unsigned>
708 switch (Level) {
710 [[fallthrough]];
712 return std::nullopt;
713 }
714
715 llvm_unreachable("Unknown TargetTransformInfo::CacheLevel");
716 }
717
718 virtual std::optional<unsigned> getMinPageSize() const { return {}; }
719
720 virtual unsigned getPrefetchDistance() const { return 0; }
721 virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses,
722 unsigned NumStridedMemAccesses,
723 unsigned NumPrefetches,
724 bool HasCall) const {
725 return 1;
726 }
727 virtual unsigned getMaxPrefetchIterationsAhead() const { return UINT_MAX; }
728 virtual bool enableWritePrefetching() const { return false; }
729 virtual bool shouldPrefetchAddressSpace(unsigned AS) const { return !AS; }
730
732 unsigned Opcode, Type *InputTypeA, Type *InputTypeB, Type *AccumType,
734 TTI::PartialReductionExtendKind OpBExtend, std::optional<unsigned> BinOp,
735 TTI::TargetCostKind CostKind, std::optional<FastMathFlags> FMF) const {
737 }
738
740 bool HasUnorderedReductions) const {
741 return 1;
742 }
743
745 unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
747 ArrayRef<const Value *> Args, const Instruction *CtxI = nullptr) const {
748 // Widenable conditions will eventually lower into constants, so some
749 // operations with them will be trivially optimized away.
750 auto IsWidenableCondition = [](const Value *V) {
751 if (auto *II = dyn_cast<IntrinsicInst>(V))
752 if (II->getIntrinsicID() == Intrinsic::experimental_widenable_condition)
753 return true;
754 return false;
755 };
756 // FIXME: A number of transformation tests seem to require these values
757 // which seems a little odd for how arbitary there are.
758 switch (Opcode) {
759 default:
760 break;
761 case Instruction::FDiv:
762 case Instruction::FRem:
763 case Instruction::SDiv:
764 case Instruction::SRem:
765 case Instruction::UDiv:
766 case Instruction::URem:
767 // FIXME: Unlikely to be true for CodeSize.
768 return TTI::TCC_Expensive;
769 case Instruction::And:
770 case Instruction::Or:
771 if (any_of(Args, IsWidenableCondition))
772 return TTI::TCC_Free;
773 break;
774 }
775
776 // Assume a 3cy latency for fp arithmetic ops.
778 if (Ty->getScalarType()->isFloatingPointTy())
779 return 3;
780
781 return 1;
782 }
783
784 virtual InstructionCost
785 getAltInstrCost(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1,
786 const SmallBitVector &OpcodeMask,
788 ArrayRef<const Value *> Scalars) const {
790 }
791
793 TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy,
795 VectorType *SubTp, ArrayRef<const Value *> Args = {},
796 const Instruction *CtxI = nullptr,
798 return 1;
799 }
800
801 virtual InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst,
802 Type *Src, TTI::CastContextHint CCH,
804 const Instruction *I) const {
805 switch (Opcode) {
806 default:
807 break;
808 case Instruction::IntToPtr: {
809 unsigned SrcSize = Src->getScalarSizeInBits();
810 if (DL.isLegalInteger(SrcSize) &&
811 SrcSize <= DL.getPointerTypeSizeInBits(Dst))
812 return 0;
813 break;
814 }
815 case Instruction::PtrToAddr: {
816 unsigned DstSize = Dst->getScalarSizeInBits();
817 assert(DstSize == DL.getAddressSizeInBits(Src));
818 if (DL.isLegalInteger(DstSize))
819 return 0;
820 break;
821 }
822 case Instruction::PtrToInt: {
823 unsigned DstSize = Dst->getScalarSizeInBits();
824 if (DL.isLegalInteger(DstSize) &&
825 DstSize >= DL.getPointerTypeSizeInBits(Src))
826 return 0;
827 break;
828 }
829 case Instruction::BitCast:
830 if (Dst == Src || (Dst->isPointerTy() && Src->isPointerTy()))
831 // Identity and pointer-to-pointer casts are free.
832 return 0;
833 break;
834 case Instruction::Trunc: {
835 // trunc to a native type is free (assuming the target has compare and
836 // shift-right of the same width).
837 TypeSize DstSize = DL.getTypeSizeInBits(Dst);
838 if (!DstSize.isScalable() && DL.isLegalInteger(DstSize.getFixedValue()))
839 return 0;
840 break;
841 }
842 }
843 return 1;
844 }
845
846 virtual InstructionCost
847 getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy,
848 unsigned Index, TTI::TargetCostKind CostKind) const {
849 return 1;
850 }
851
852 virtual InstructionCost getCFInstrCost(unsigned Opcode,
854 const Instruction *I = nullptr) const {
855 // A phi would be free, unless we're costing the throughput because it
856 // will require a register.
857 if (Opcode == Instruction::PHI && CostKind != TTI::TCK_RecipThroughput)
858 return 0;
859 return 1;
860 }
861
863 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
865 TTI::OperandValueInfo Op2Info, const Instruction *I) const {
866 return 1;
867 }
868
870 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
871 const Value *Op0, const Value *Op1,
873 return 1;
874 }
875
876 /// \param ScalarUserAndIdx encodes the information about extracts from a
877 /// vector with 'Scalar' being the value being extracted,'User' being the user
878 /// of the extract(nullptr if user is not known before vectorization) and
879 /// 'Idx' being the extract lane.
881 unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index,
882 Value *Scalar,
883 ArrayRef<std::tuple<Value *, User *, int>> ScalarUserAndIdx,
885 return 1;
886 }
887
890 unsigned Index,
892 return 1;
893 }
894
895 virtual InstructionCost
898 unsigned Index) const {
899 return 1;
900 }
901
902 virtual InstructionCost
903 getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF,
904 const APInt &DemandedDstElts,
906 return 1;
907 }
908
909 virtual InstructionCost
912 // Note: The `insertvalue` cost here is chosen to match the default case of
913 // getInstructionCost() -- as prior to adding this helper `insertvalue` was
914 // not handled.
915 if (Opcode == Instruction::InsertValue &&
917 return TTI::TCC_Basic;
918 return TTI::TCC_Free;
919 }
920
921 virtual InstructionCost
922 getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment,
924 TTI::OperandValueInfo OpInfo, const Instruction *I) const {
925 return 1;
926 }
927
929 unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
930 Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
931 bool UseMaskForCond, bool UseMaskForGaps) const {
932 return 1;
933 }
934
935 virtual InstructionCost
938 switch (ICA.getID()) {
939 default:
940 break;
941 case Intrinsic::allow_runtime_check:
942 case Intrinsic::allow_ubsan_check:
943 case Intrinsic::annotation:
944 case Intrinsic::assume:
945 case Intrinsic::sideeffect:
946 case Intrinsic::pseudoprobe:
947 case Intrinsic::arithmetic_fence:
948 case Intrinsic::dbg_assign:
949 case Intrinsic::dbg_declare:
950 case Intrinsic::dbg_value:
951 case Intrinsic::dbg_label:
952 case Intrinsic::invariant_start:
953 case Intrinsic::invariant_end:
954 case Intrinsic::launder_invariant_group:
955 case Intrinsic::is_constant:
956 case Intrinsic::lifetime_start:
957 case Intrinsic::lifetime_end:
958 case Intrinsic::experimental_noalias_scope_decl:
959 case Intrinsic::objectsize:
960 case Intrinsic::ptr_annotation:
961 case Intrinsic::var_annotation:
962 case Intrinsic::experimental_gc_result:
963 case Intrinsic::experimental_gc_relocate:
964 case Intrinsic::coro_alloc:
965 case Intrinsic::coro_begin:
966 case Intrinsic::coro_begin_custom_abi:
967 case Intrinsic::coro_dead:
968 case Intrinsic::coro_id:
969 case Intrinsic::coro_id_async:
970 case Intrinsic::coro_id_retcon:
971 case Intrinsic::coro_id_retcon_once:
972 case Intrinsic::coro_noop:
973 case Intrinsic::coro_free:
974 case Intrinsic::coro_end:
975 case Intrinsic::coro_frame:
976 case Intrinsic::coro_size:
977 case Intrinsic::coro_align:
978 case Intrinsic::coro_suspend:
979 case Intrinsic::coro_subfn_addr:
980 case Intrinsic::threadlocal_address:
981 case Intrinsic::experimental_widenable_condition:
982 case Intrinsic::ssa_copy:
983 // These intrinsics don't actually represent code after lowering.
984 return 0;
985 case Intrinsic::bswap:
986 if (!ICA.getReturnType()->isVectorTy() &&
987 !isPowerOf2_64(DL.getTypeSizeInBits(ICA.getReturnType())))
989 }
990 return 1;
991 }
992
993 virtual InstructionCost
996 switch (MICA.getID()) {
997 case Intrinsic::masked_scatter:
998 case Intrinsic::masked_gather:
999 case Intrinsic::masked_load:
1000 case Intrinsic::masked_store:
1001 case Intrinsic::vp_scatter:
1002 case Intrinsic::vp_gather:
1003 case Intrinsic::masked_compressstore:
1004 case Intrinsic::masked_expandload:
1005 case Intrinsic::speculative_load:
1006 return 1;
1007 }
1009 }
1010
1012 ArrayRef<Type *> Tys,
1014 return 1;
1015 }
1016
1017 // Assume that we have a register of the right size for the type.
1018 virtual unsigned getNumberOfParts(Type *Tp) const { return 1; }
1019
1022 const SCEV *,
1023 TTI::TargetCostKind) const {
1024 return 0;
1025 }
1026
1027 virtual InstructionCost
1029 std::optional<FastMathFlags> FMF,
1030 TTI::TargetCostKind) const {
1031 return 1;
1032 }
1033
1036 TTI::TargetCostKind) const {
1037 return 1;
1038 }
1039
1040 virtual InstructionCost
1041 getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy,
1042 VectorType *Ty, std::optional<FastMathFlags> FMF,
1044 return 1;
1045 }
1046
1047 virtual InstructionCost
1048 getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy,
1050 return 1;
1051 }
1052
1053 virtual InstructionCost
1055 return 0;
1056 }
1057
1059 MemIntrinsicInfo &Info) const {
1060 return false;
1061 }
1062
1063 virtual unsigned getAtomicMemIntrinsicMaxElementSize() const {
1064 // Note for overrides: You must ensure for all element unordered-atomic
1065 // memory intrinsics that all power-of-2 element sizes up to, and
1066 // including, the return value of this method have a corresponding
1067 // runtime lib call. These runtime lib call definitions can be found
1068 // in RuntimeLibcalls.h
1069 return 0;
1070 }
1071
1072 virtual Value *
1074 bool CanCreate = true) const {
1075 return nullptr;
1076 }
1077
1078 virtual Type *
1080 unsigned SrcAddrSpace, unsigned DestAddrSpace,
1081 Align SrcAlign, Align DestAlign,
1082 std::optional<uint32_t> AtomicElementSize) const {
1083 return AtomicElementSize ? Type::getIntNTy(Context, *AtomicElementSize * 8)
1084 : Type::getInt8Ty(Context);
1085 }
1086
1088 SmallVectorImpl<Type *> &OpsOut, LLVMContext &Context,
1089 unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace,
1090 Align SrcAlign, Align DestAlign,
1091 std::optional<uint32_t> AtomicCpySize) const {
1092 unsigned OpSizeInBytes = AtomicCpySize.value_or(1);
1093 Type *OpType = Type::getIntNTy(Context, OpSizeInBytes * 8);
1094 for (unsigned i = 0; i != RemainingBytes; i += OpSizeInBytes)
1095 OpsOut.push_back(OpType);
1096 }
1097
1098 virtual bool areInlineCompatible(const Function *Caller,
1099 const Function *Callee) const {
1100 return (Caller->getFnAttribute("target-cpu") ==
1101 Callee->getFnAttribute("target-cpu")) &&
1102 (Caller->getFnAttribute("target-features") ==
1103 Callee->getFnAttribute("target-features"));
1104 }
1105
1106 virtual unsigned getInlineCallPenalty(const Function *F, const CallBase &Call,
1107 unsigned DefaultCallPenalty) const {
1108 return DefaultCallPenalty;
1109 }
1110
1111 virtual bool
1113 const Attribute &Attr) const {
1114 // Copy attributes by default
1115 return true;
1116 }
1117
1118 virtual bool areTypesABICompatible(const Function *Caller,
1119 const Function *Callee,
1120 ArrayRef<Type *> Types) const {
1121 return (Caller->getFnAttribute("target-cpu") ==
1122 Callee->getFnAttribute("target-cpu")) &&
1123 (Caller->getFnAttribute("target-features") ==
1124 Callee->getFnAttribute("target-features"));
1125 }
1126
1128 return false;
1129 }
1130
1132 return false;
1133 }
1134
1135 virtual unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const {
1136 return 128;
1137 }
1138
1139 virtual bool isLegalToVectorizeLoad(LoadInst *LI) const { return true; }
1140
1141 virtual bool isLegalToVectorizeStore(StoreInst *SI) const { return true; }
1142
1143 virtual bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes,
1144 Align Alignment,
1145 unsigned AddrSpace) const {
1146 return true;
1147 }
1148
1149 virtual bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes,
1150 Align Alignment,
1151 unsigned AddrSpace) const {
1152 return true;
1153 }
1154
1156 ElementCount VF) const {
1157 return true;
1158 }
1159
1161 ArrayRef<int> Mask, ArrayRef<Value *> Scalars,
1164 GatherUseOps) const {
1165 return TargetTransformInfo::VectorInstrContext::None;
1166 }
1167
1169 return true;
1170 }
1171
1172 virtual unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize,
1173 unsigned ChainSizeInBytes,
1174 VectorType *VecTy) const {
1175 return VF;
1176 }
1177
1178 virtual unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize,
1179 unsigned ChainSizeInBytes,
1180 VectorType *VecTy) const {
1181 return VF;
1182 }
1183
1184 virtual bool preferFixedOverScalableIfEqualCost() const { return false; }
1185
1186 virtual bool preferInLoopReduction(RecurKind Kind, Type *Ty) const {
1187 return false;
1188 }
1189 virtual bool preferAlternateOpcodeVectorization() const { return true; }
1190
1191 virtual bool preferSLPInstCountCheck() const { return true; }
1192
1193 virtual bool preferPredicatedReductionSelect() const { return false; }
1194
1195 virtual bool preferEpilogueVectorization(ElementCount Iters) const {
1196 // We consider epilogue vectorization unprofitable for targets that
1197 // don't consider interleaving beneficial (eg. MVE).
1198 return getMaxInterleaveFactor(Iters, false) > 1;
1199 }
1200
1201 virtual bool shouldConsiderVectorizationRegPressure() const { return false; }
1202
1203 virtual bool shouldExpandReduction(const IntrinsicInst *II) const {
1204 return true;
1205 }
1206
1207 virtual TTI::ReductionShuffle
1211
1212 virtual unsigned getGISelRematGlobalCost() const { return 1; }
1213
1214 virtual unsigned getMinTripCountTailFoldingThreshold() const { return 0; }
1215
1216 virtual bool supportsScalableVectors() const { return false; }
1217
1218 virtual bool enableScalableVectorization() const { return false; }
1219
1220 virtual bool hasActiveVectorLength() const { return false; }
1221
1223 SmallVectorImpl<Use *> &Ops) const {
1224 return false;
1225 }
1226
1227 virtual bool isVectorShiftByScalarCheap(Type *Ty) const { return false; }
1228
1235
1236 virtual bool hasArmWideBranch(bool) const { return false; }
1237
1238 virtual APInt getFeatureMask(const Function &F) const {
1239 return APInt::getZero(32);
1240 }
1241
1242 virtual APInt getPriorityMask(const Function &F) const {
1243 return APInt::getZero(32);
1244 }
1245
1246 virtual bool isMultiversionedFunction(const Function &F) const {
1247 return false;
1248 }
1249
1250 virtual unsigned getMaxNumArgs() const { return UINT_MAX; }
1251
1252 virtual unsigned getNumBytesToPadGlobalArray(unsigned Size,
1253 Type *ArrayType) const {
1254 return 0;
1255 }
1256
1258 const Function &F,
1259 SmallVectorImpl<std::pair<StringRef, int64_t>> &LB) const {}
1260
1261 virtual bool allowVectorElementIndexingUsingGEP() const { return true; }
1262
1263 virtual bool isUniform(const Instruction *I,
1264 const SmallBitVector &UniformArgs) const {
1265 llvm_unreachable("target must implement isUniform for Custom uniformity");
1266 }
1267
1268protected:
1269 // Obtain the minimum required size to hold the value (without the sign)
1270 // In case of a vector it returns the min required size for one element.
1271 unsigned minRequiredElementSize(const Value *Val, bool &isSigned) const {
1273 const auto *VectorValue = cast<Constant>(Val);
1274
1275 // In case of a vector need to pick the max between the min
1276 // required size for each element
1277 auto *VT = cast<FixedVectorType>(Val->getType());
1278
1279 // Assume unsigned elements
1280 isSigned = false;
1281
1282 // The max required size is the size of the vector element type
1283 unsigned MaxRequiredSize =
1284 VT->getElementType()->getPrimitiveSizeInBits().getFixedValue();
1285
1286 unsigned MinRequiredSize = 0;
1287 for (unsigned i = 0, e = VT->getNumElements(); i < e; ++i) {
1288 if (auto *IntElement =
1289 dyn_cast<ConstantInt>(VectorValue->getAggregateElement(i))) {
1290 bool signedElement = IntElement->getValue().isNegative();
1291 // Get the element min required size.
1292 unsigned ElementMinRequiredSize =
1293 IntElement->getValue().getSignificantBits() - 1;
1294 // In case one element is signed then all the vector is signed.
1295 isSigned |= signedElement;
1296 // Save the max required bit size between all the elements.
1297 MinRequiredSize = std::max(MinRequiredSize, ElementMinRequiredSize);
1298 } else {
1299 // not an int constant element
1300 return MaxRequiredSize;
1301 }
1302 }
1303 return MinRequiredSize;
1304 }
1305
1306 if (const auto *CI = dyn_cast<ConstantInt>(Val)) {
1307 isSigned = CI->getValue().isNegative();
1308 return CI->getValue().getSignificantBits() - 1;
1309 }
1310
1311 if (const auto *Cast = dyn_cast<SExtInst>(Val)) {
1312 isSigned = true;
1313 return Cast->getSrcTy()->getScalarSizeInBits() - 1;
1314 }
1315
1316 if (const auto *Cast = dyn_cast<ZExtInst>(Val)) {
1317 isSigned = false;
1318 return Cast->getSrcTy()->getScalarSizeInBits();
1319 }
1320
1321 isSigned = false;
1322 return Val->getType()->getScalarSizeInBits();
1323 }
1324
1325 bool isStridedAccess(const SCEV *Ptr) const {
1326 return Ptr && isa<SCEVAddRecExpr>(Ptr);
1327 }
1328
1330 const SCEV *Ptr) const {
1331 if (!isStridedAccess(Ptr))
1332 return nullptr;
1333 const SCEVAddRecExpr *AddRec = cast<SCEVAddRecExpr>(Ptr);
1334 return dyn_cast<SCEVConstant>(AddRec->getStepRecurrence(*SE));
1335 }
1336
1338 int64_t MergeDistance) const {
1339 const SCEVConstant *Step = getConstantStrideStep(SE, Ptr);
1340 if (!Step)
1341 return false;
1342 APInt StrideVal = Step->getAPInt();
1343 if (StrideVal.getBitWidth() > 64)
1344 return false;
1345 // FIXME: Need to take absolute value for negative stride case.
1346 return StrideVal.getSExtValue() < MergeDistance;
1347 }
1348};
1349
1350/// CRTP base class for use as a mix-in that aids implementing
1351/// a TargetTransformInfo-compatible class.
1352template <typename T>
1354private:
1355 typedef TargetTransformInfoImplBase BaseT;
1356
1357protected:
1359
1360public:
1361 InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr,
1364 Type *AccessType) const override {
1365 assert(PointeeType && Ptr && "can't get GEPCost of nullptr");
1366 auto *BaseGV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts());
1367 bool HasBaseReg = (BaseGV == nullptr);
1368
1369 auto PtrSizeBits = DL.getPointerTypeSizeInBits(Ptr->getType());
1370 APInt BaseOffset(PtrSizeBits, 0);
1371 int64_t Scale = 0;
1372
1373 auto GTI = gep_type_begin(PointeeType, Operands);
1374 Type *TargetType = nullptr;
1375
1376 // Handle the case where the GEP instruction has a single operand,
1377 // the basis, therefore TargetType is a nullptr.
1378 if (Operands.empty())
1379 return !BaseGV ? TTI::TCC_Free : TTI::TCC_Basic;
1380
1381 for (auto I = Operands.begin(); I != Operands.end(); ++I, ++GTI) {
1382 TargetType = GTI.getIndexedType();
1383 // We assume that the cost of Scalar GEP with constant index and the
1384 // cost of Vector GEP with splat constant index are the same.
1385 const ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
1386 if (!ConstIdx)
1387 if (auto Splat = getSplatValue(*I))
1388 ConstIdx = dyn_cast<ConstantInt>(Splat);
1389 if (StructType *STy = GTI.getStructTypeOrNull()) {
1390 // For structures the index is always splat or scalar constant
1391 assert(ConstIdx && "Unexpected GEP index");
1392 uint64_t Field = ConstIdx->getZExtValue();
1393 BaseOffset += DL.getStructLayout(STy)->getElementOffset(Field);
1394 } else {
1395 // If this operand is a scalable type, bail out early.
1396 // TODO: Make isLegalAddressingMode TypeSize aware.
1397 if (TargetType->isScalableTy())
1398 return TTI::TCC_Basic;
1399 int64_t ElementSize =
1400 GTI.getSequentialElementStride(DL).getFixedValue();
1401 if (ConstIdx) {
1402 BaseOffset +=
1403 ConstIdx->getValue().sextOrTrunc(PtrSizeBits) * ElementSize;
1404 } else {
1405 // Needs scale register.
1406 if (Scale != 0)
1407 // No addressing mode takes two scale registers.
1408 return TTI::TCC_Basic;
1409 Scale = ElementSize;
1410 }
1411 }
1412 }
1413
1414 // If we haven't been provided a hint, use the target type for now.
1415 //
1416 // TODO: Take a look at potentially removing this: This is *slightly* wrong
1417 // as it's possible to have a GEP with a foldable target type but a memory
1418 // access that isn't foldable. For example, this load isn't foldable on
1419 // RISC-V:
1420 //
1421 // %p = getelementptr i32, ptr %base, i32 42
1422 // %x = load <2 x i32>, ptr %p
1423 if (!AccessType)
1424 AccessType = TargetType;
1425
1426 // If the final address of the GEP is a legal addressing mode for the given
1427 // access type, then we can fold it into its users.
1428 if (static_cast<const T *>(this)->isLegalAddressingMode(
1429 AccessType, const_cast<GlobalValue *>(BaseGV),
1430 BaseOffset.sextOrTrunc(64).getSExtValue(), HasBaseReg, Scale,
1432 return TTI::TCC_Free;
1433
1434 // TODO: Instead of returning TCC_Basic here, we should use
1435 // getArithmeticInstrCost. Or better yet, provide a hook to let the target
1436 // model it.
1437 return TTI::TCC_Basic;
1438 }
1439
1442 const TTI::PointersChainInfo &Info, Type *AccessTy,
1443 TTI::TargetCostKind CostKind) const override {
1445 // In the basic model we take into account GEP instructions only
1446 // (although here can come alloca instruction, a value, constants and/or
1447 // constant expressions, PHIs, bitcasts ... whatever allowed to be used as a
1448 // pointer). Typically, if Base is a not a GEP-instruction and all the
1449 // pointers are relative to the same base address, all the rest are
1450 // either GEP instructions, PHIs, bitcasts or constants. When we have same
1451 // base, we just calculate cost of each non-Base GEP as an ADD operation if
1452 // any their index is a non-const.
1453 // If no known dependecies between the pointers cost is calculated as a sum
1454 // of costs of GEP instructions.
1455 for (const Value *V : Ptrs) {
1456 const auto *GEP = dyn_cast<GetElementPtrInst>(V);
1457 if (!GEP)
1458 continue;
1459 if (Info.isSameBase() && V != Base) {
1460 if (GEP->hasAllConstantIndices())
1461 continue;
1462 Cost += static_cast<const T *>(this)->getArithmeticInstrCost(
1463 Instruction::Add, GEP->getType(), CostKind,
1464 {TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None},
1465 {});
1466 } else {
1467 SmallVector<const Value *> Indices(GEP->indices());
1468 Cost += static_cast<const T *>(this)->getGEPCost(
1469 GEP->getSourceElementType(), GEP->getPointerOperand(), Indices,
1470 CostKind, AccessTy);
1471 }
1472 }
1473 return Cost;
1474 }
1475
1478 TTI::TargetCostKind CostKind) const override {
1479 using namespace llvm::PatternMatch;
1480
1481 auto *TargetTTI = static_cast<const T *>(this);
1482 // Handle non-intrinsic calls, invokes, and callbr.
1483 // FIXME: Unlikely to be true for anything but CodeSize.
1484 auto *CB = dyn_cast<CallBase>(U);
1485 if (CB && !isa<IntrinsicInst>(U)) {
1486 if (const Function *F = CB->getCalledFunction()) {
1487 if (!TargetTTI->isLoweredToCall(F))
1488 return TTI::TCC_Basic; // Give a basic cost if it will be lowered
1489
1490 return TTI::TCC_Basic * (F->getFunctionType()->getNumParams() + 1);
1491 }
1492 // For indirect or other calls, scale cost by number of arguments.
1493 return TTI::TCC_Basic * (CB->arg_size() + 1);
1494 }
1495
1496 Type *Ty = U->getType();
1497 unsigned Opcode = Operator::getOpcode(U);
1498 auto *I = dyn_cast<Instruction>(U);
1499 switch (Opcode) {
1500 default:
1501 break;
1502 case Instruction::Call: {
1503 assert(isa<IntrinsicInst>(U) && "Unexpected non-intrinsic call");
1504 auto *Intrinsic = cast<IntrinsicInst>(U);
1505 IntrinsicCostAttributes CostAttrs(Intrinsic->getIntrinsicID(), *CB);
1506 return TargetTTI->getIntrinsicInstrCost(CostAttrs, CostKind);
1507 }
1508 case Instruction::UncondBr:
1509 case Instruction::CondBr:
1510 case Instruction::Ret:
1511 case Instruction::PHI:
1512 case Instruction::Switch:
1513 return TargetTTI->getCFInstrCost(Opcode, CostKind, I);
1514 case Instruction::Freeze:
1515 return TTI::TCC_Free;
1516 case Instruction::ExtractValue:
1517 case Instruction::InsertValue:
1518 return TargetTTI->getInsertExtractValueCost(Opcode, CostKind);
1519 case Instruction::Alloca:
1520 if (cast<AllocaInst>(U)->isStaticAlloca())
1521 return TTI::TCC_Free;
1522 break;
1523 case Instruction::GetElementPtr: {
1524 const auto *GEP = cast<GEPOperator>(U);
1525 Type *AccessType = nullptr;
1526 // For now, only provide the AccessType in the simple case where the GEP
1527 // only has one user.
1528 if (GEP->hasOneUser() && I)
1529 AccessType = I->user_back()->getAccessType();
1530
1531 return TargetTTI->getGEPCost(GEP->getSourceElementType(),
1532 Operands.front(), Operands.drop_front(),
1533 CostKind, AccessType);
1534 }
1535 case Instruction::Add:
1536 case Instruction::FAdd:
1537 case Instruction::Sub:
1538 case Instruction::FSub:
1539 case Instruction::Mul:
1540 case Instruction::FMul:
1541 case Instruction::UDiv:
1542 case Instruction::SDiv:
1543 case Instruction::FDiv:
1544 case Instruction::URem:
1545 case Instruction::SRem:
1546 case Instruction::FRem:
1547 case Instruction::Shl:
1548 case Instruction::LShr:
1549 case Instruction::AShr:
1550 case Instruction::And:
1551 case Instruction::Or:
1552 case Instruction::Xor:
1553 case Instruction::FNeg: {
1555 TTI::OperandValueInfo Op2Info;
1556 if (Opcode != Instruction::FNeg)
1557 Op2Info = TTI::getOperandInfo(Operands[1]);
1558 return TargetTTI->getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info,
1559 Op2Info, Operands, I);
1560 }
1561 case Instruction::IntToPtr:
1562 case Instruction::PtrToAddr:
1563 case Instruction::PtrToInt:
1564 case Instruction::SIToFP:
1565 case Instruction::UIToFP:
1566 case Instruction::FPToUI:
1567 case Instruction::FPToSI:
1568 case Instruction::Trunc:
1569 case Instruction::FPTrunc:
1570 case Instruction::BitCast:
1571 case Instruction::FPExt:
1572 case Instruction::SExt:
1573 case Instruction::ZExt:
1574 case Instruction::AddrSpaceCast: {
1575 Type *OpTy = Operands[0]->getType();
1576 return TargetTTI->getCastInstrCost(
1577 Opcode, Ty, OpTy, TTI::getCastContextHint(I), CostKind, I);
1578 }
1579 case Instruction::Store: {
1580 auto *SI = cast<StoreInst>(U);
1581 Type *ValTy = Operands[0]->getType();
1583 return TargetTTI->getMemoryOpCost(Opcode, ValTy, SI->getAlign(),
1584 SI->getPointerAddressSpace(), CostKind,
1585 OpInfo, I);
1586 }
1587 case Instruction::Load: {
1588 auto *LI = cast<LoadInst>(U);
1589 Type *LoadType = U->getType();
1590 // If there is a non-register sized type, the cost estimation may expand
1591 // it to be several instructions to load into multiple registers on the
1592 // target. But, if the only use of the load is a trunc instruction to a
1593 // register sized type, the instruction selector can combine these
1594 // instructions to be a single load. So, in this case, we use the
1595 // destination type of the trunc instruction rather than the load to
1596 // accurately estimate the cost of this load instruction.
1597 if (CostKind == TTI::TCK_CodeSize && LI->hasOneUse() &&
1598 !LoadType->isVectorTy()) {
1599 if (const TruncInst *TI = dyn_cast<TruncInst>(*LI->user_begin()))
1600 LoadType = TI->getDestTy();
1601 }
1602 return TargetTTI->getMemoryOpCost(Opcode, LoadType, LI->getAlign(),
1604 {TTI::OK_AnyValue, TTI::OP_None}, I);
1605 }
1606 case Instruction::Select: {
1607 const Value *Op0, *Op1;
1608 if (match(U, m_LogicalAnd(m_Value(Op0), m_Value(Op1))) ||
1609 match(U, m_LogicalOr(m_Value(Op0), m_Value(Op1)))) {
1610 // select x, y, false --> x & y
1611 // select x, true, y --> x | y
1612 const auto Op1Info = TTI::getOperandInfo(Op0);
1613 const auto Op2Info = TTI::getOperandInfo(Op1);
1614 assert(Op0->getType()->getScalarSizeInBits() == 1 &&
1615 Op1->getType()->getScalarSizeInBits() == 1);
1616
1618 return TargetTTI->getArithmeticInstrCost(
1619 match(U, m_LogicalOr()) ? Instruction::Or : Instruction::And, Ty,
1620 CostKind, Op1Info, Op2Info, Operands, I);
1621 }
1622 const auto Op1Info = TTI::getOperandInfo(Operands[1]);
1623 const auto Op2Info = TTI::getOperandInfo(Operands[2]);
1624 Type *CondTy = Operands[0]->getType();
1625 return TargetTTI->getCmpSelInstrCost(Opcode, U->getType(), CondTy,
1627 CostKind, Op1Info, Op2Info, I);
1628 }
1629 case Instruction::ICmp:
1630 case Instruction::FCmp: {
1631 const auto Op1Info = TTI::getOperandInfo(Operands[0]);
1632 const auto Op2Info = TTI::getOperandInfo(Operands[1]);
1633 Type *ValTy = Operands[0]->getType();
1634 // TODO: Also handle ICmp/FCmp constant expressions.
1635 return TargetTTI->getCmpSelInstrCost(Opcode, ValTy, U->getType(),
1636 I ? cast<CmpInst>(I)->getPredicate()
1638 CostKind, Op1Info, Op2Info, I);
1639 }
1640 case Instruction::InsertElement: {
1641 auto *IE = dyn_cast<InsertElementInst>(U);
1642 if (!IE)
1643 return TTI::TCC_Basic; // FIXME
1644 unsigned Idx = -1;
1645 if (auto *CI = dyn_cast<ConstantInt>(Operands[2]))
1646 if (CI->getValue().getActiveBits() <= 32)
1647 Idx = CI->getZExtValue();
1648 return TargetTTI->getVectorInstrCost(*IE, Ty, CostKind, Idx,
1650 }
1651 case Instruction::ShuffleVector: {
1652 auto *Shuffle = dyn_cast<ShuffleVectorInst>(U);
1653 if (!Shuffle)
1654 return TTI::TCC_Basic; // FIXME
1655
1656 auto *VecTy = cast<VectorType>(U->getType());
1657 auto *VecSrcTy = cast<VectorType>(Operands[0]->getType());
1658 ArrayRef<int> Mask = Shuffle->getShuffleMask();
1659 int NumSubElts, SubIndex;
1660
1661 // Treat undef/poison mask as free (no matter the length).
1662 if (all_of(Mask, [](int M) { return M < 0; }))
1663 return TTI::TCC_Free;
1664
1665 // TODO: move more of this inside improveShuffleKindFromMask.
1666 if (Shuffle->changesLength()) {
1667 // Treat a 'subvector widening' as a free shuffle.
1668 if (Shuffle->increasesLength() && Shuffle->isIdentityWithPadding())
1669 return TTI::TCC_Free;
1670
1671 if (Shuffle->isExtractSubvectorMask(SubIndex))
1672 return TargetTTI->getShuffleCost(TTI::SK_ExtractSubvector, VecTy,
1673 VecSrcTy, CostKind, Mask, SubIndex,
1674 VecTy, Operands, Shuffle);
1675
1676 if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
1677 return TargetTTI->getShuffleCost(
1678 TTI::SK_InsertSubvector, VecTy, VecSrcTy, CostKind, Mask,
1679 SubIndex,
1680 FixedVectorType::get(VecTy->getScalarType(), NumSubElts),
1681 Operands, Shuffle);
1682
1683 int ReplicationFactor, VF;
1684 if (Shuffle->isReplicationMask(ReplicationFactor, VF)) {
1685 APInt DemandedDstElts = APInt::getZero(Mask.size());
1686 for (auto I : enumerate(Mask)) {
1687 if (I.value() != PoisonMaskElem)
1688 DemandedDstElts.setBit(I.index());
1689 }
1690 return TargetTTI->getReplicationShuffleCost(
1691 VecSrcTy->getElementType(), ReplicationFactor, VF,
1692 DemandedDstElts, CostKind);
1693 }
1694
1695 bool IsUnary = isa<UndefValue>(Operands[1]);
1696 NumSubElts = VecSrcTy->getElementCount().getKnownMinValue();
1697 SmallVector<int, 16> AdjustMask(Mask);
1698
1699 // Widening shuffle - widening the source(s) to the new length
1700 // (treated as free - see above), and then perform the adjusted
1701 // shuffle at that width.
1702 if (Shuffle->increasesLength()) {
1703 for (int &M : AdjustMask)
1704 M = M >= NumSubElts ? (M + (Mask.size() - NumSubElts)) : M;
1705
1706 return TargetTTI->getShuffleCost(
1708 VecTy, CostKind, AdjustMask, 0, nullptr, Operands, Shuffle);
1709 }
1710
1711 // Narrowing shuffle - perform shuffle at original wider width and
1712 // then extract the lower elements.
1713 // FIXME: This can assume widening, which is not true of all vector
1714 // architectures (and is not even the default).
1715 AdjustMask.append(NumSubElts - Mask.size(), PoisonMaskElem);
1716
1717 InstructionCost ShuffleCost = TargetTTI->getShuffleCost(
1719 VecSrcTy, VecSrcTy, CostKind, AdjustMask, 0, nullptr, Operands,
1720 Shuffle);
1721
1722 SmallVector<int, 16> ExtractMask(Mask.size());
1723 std::iota(ExtractMask.begin(), ExtractMask.end(), 0);
1724 return ShuffleCost + TargetTTI->getShuffleCost(
1725 TTI::SK_ExtractSubvector, VecTy, VecSrcTy,
1726 CostKind, ExtractMask, 0, VecTy, {}, Shuffle);
1727 }
1728
1729 if (Shuffle->isIdentity())
1730 return TTI::TCC_Free;
1731
1732 if (Shuffle->isReverse())
1733 return TargetTTI->getShuffleCost(TTI::SK_Reverse, VecTy, VecSrcTy,
1734 CostKind, Mask, 0, nullptr, Operands,
1735 Shuffle);
1736
1737 if (Shuffle->isTranspose())
1738 return TargetTTI->getShuffleCost(TTI::SK_Transpose, VecTy, VecSrcTy,
1739 CostKind, Mask, 0, nullptr, Operands,
1740 Shuffle);
1741
1742 if (Shuffle->isZeroEltSplat())
1743 return TargetTTI->getShuffleCost(TTI::SK_Broadcast, VecTy, VecSrcTy,
1744 CostKind, Mask, 0, nullptr, Operands,
1745 Shuffle);
1746
1747 if (Shuffle->isSingleSource())
1748 return TargetTTI->getShuffleCost(TTI::SK_PermuteSingleSrc, VecTy,
1749 VecSrcTy, CostKind, Mask, 0, nullptr,
1750 Operands, Shuffle);
1751
1752 if (Shuffle->isInsertSubvectorMask(NumSubElts, SubIndex))
1753 return TargetTTI->getShuffleCost(
1754 TTI::SK_InsertSubvector, VecTy, VecSrcTy, CostKind, Mask, SubIndex,
1755 FixedVectorType::get(VecTy->getScalarType(), NumSubElts), Operands,
1756 Shuffle);
1757
1758 if (Shuffle->isSelect())
1759 return TargetTTI->getShuffleCost(TTI::SK_Select, VecTy, VecSrcTy,
1760 CostKind, Mask, 0, nullptr, Operands,
1761 Shuffle);
1762
1763 if (Shuffle->isSplice(SubIndex))
1764 return TargetTTI->getShuffleCost(TTI::SK_Splice, VecTy, VecSrcTy,
1765 CostKind, Mask, SubIndex, nullptr,
1766 Operands, Shuffle);
1767
1768 return TargetTTI->getShuffleCost(TTI::SK_PermuteTwoSrc, VecTy, VecSrcTy,
1769 CostKind, Mask, 0, nullptr, Operands,
1770 Shuffle);
1771 }
1772 case Instruction::ExtractElement: {
1773 auto *EEI = dyn_cast<ExtractElementInst>(U);
1774 if (!EEI)
1775 return TTI::TCC_Basic; // FIXME
1776 unsigned Idx = -1;
1777 if (auto *CI = dyn_cast<ConstantInt>(Operands[1]))
1778 if (CI->getValue().getActiveBits() <= 32)
1779 Idx = CI->getZExtValue();
1780 Type *DstTy = Operands[0]->getType();
1781 return TargetTTI->getVectorInstrCost(*EEI, DstTy, CostKind, Idx);
1782 }
1783 }
1784
1785 // By default, just classify everything remaining as 'basic'.
1786 return TTI::TCC_Basic;
1787 }
1788
1790 auto *TargetTTI = static_cast<const T *>(this);
1791 SmallVector<const Value *, 4> Ops(I->operand_values());
1792 InstructionCost Cost = TargetTTI->getInstructionCost(
1795 }
1796
1797 bool supportsTailCallFor(const CallBase *CB) const override {
1798 return static_cast<const T *>(this)->supportsTailCalls();
1799 }
1800};
1801} // namespace llvm
1802
1803#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Imm
unsigned uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:215
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")))
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
static bool isSigned(unsigned Opcode)
Hexagon Common GEP
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#define T
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")))
SI Fold Operands
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
This pass exposes codegen information to IR-level passes.
static void computeKnownBits(const Value *V, const APInt &DemandedElts, KnownBits &Known, const SimplifyQuery &Q, unsigned Depth)
Determine which bits of V are known to be either zero or one and return them in the Known bit set.
Class for arbitrary precision integers.
Definition APInt.h:78
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
Definition APInt.h:1350
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition APInt.h:1508
LLVM_ABI APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Definition APInt.cpp:1086
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition APInt.h:196
int64_t getSExtValue() const
Get sign extended value.
Definition APInt.h:1582
This class represents a conversion between pointers from one address space to another.
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Class to represent array types.
A cache of @llvm.assume calls within a function.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:106
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...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition InstrTypes.h:740
Conditional Branch instruction.
This is the shared class of boolean and integer constants.
Definition Constants.h:87
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Definition Constants.h:168
const APInt & getValue() const
Return the constant as an APInt value reference.
Definition Constants.h:159
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition TypeSize.h:311
Convenience struct for specifying and reasoning about fast-math flags.
Definition FMF.h:23
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition Type.cpp:843
The core instruction combiner logic.
static InstructionCost getInvalid(CostType Val=0)
A wrapper class for inspecting calls to intrinsic functions.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
An instruction for reading from memory.
Represents a single loop in the control flow graph.
Definition LoopInfo.h:40
Information for memory intrinsic cost model.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
Definition Operator.h:43
The optimization diagnostic interface.
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.
SCEVUse 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.
Definition TypeSize.h:30
static StackOffset getScalable(int64_t Scalable)
Definition TypeSize.h:40
static StackOffset getFixed(int64_t Fixed)
Definition TypeSize.h:39
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent struct types.
Multiway switch.
Provides information about what library functions are available for the current target.
virtual bool preferAlternateOpcodeVectorization() const
virtual bool isProfitableLSRChainElement(Instruction *I) const
virtual unsigned getCallerAllocaCost(const CallBase *CB, const AllocaInst *AI) const
virtual unsigned getMinimumLookupTableEntryBitWidth() const
virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const
virtual InstructionCost getCostOfKeepingLiveOverCall(ArrayRef< Type * > Tys) const
virtual TailFoldingStyle getPreferredTailFoldingStyle() const
virtual unsigned getMaximumVF(unsigned ElemWidth, unsigned Opcode) const
virtual bool preferFixedOverScalableIfEqualCost() const
virtual InstructionCost getMulAccReductionCost(bool IsUnsigned, unsigned RedOpcode, Type *ResTy, VectorType *Ty, TTI::TargetCostKind CostKind) const
virtual const DataLayout & getDataLayout() const
virtual std::optional< unsigned > getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const
virtual InstructionCost getCallInstrCost(Function *F, Type *RetTy, ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind) const
virtual bool enableInterleavedAccessVectorization() const
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, std::optional< FastMathFlags > FMF) const
virtual unsigned getAddressSpaceJoin(unsigned AS1, unsigned AS2) const
virtual InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info, TTI::OperandValueInfo Opd2Info, ArrayRef< const Value * > Args, const Instruction *CtxI=nullptr) const
virtual InstructionCost getOperandsScalarizationOverhead(ArrayRef< Type * > Tys, TTI::TargetCostKind CostKind, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual InstructionCost getFPOpCost(Type *Ty) const
virtual bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment) const
virtual TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
virtual bool isLegalToVectorizeLoadChain(unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
bool isStridedAccess(const SCEV *Ptr) const
virtual unsigned getAtomicMemIntrinsicMaxElementSize() const
virtual Value * rewriteIntrinsicWithAddressSpace(IntrinsicInst *II, Value *OldV, Value *NewV) const
virtual bool hasMultiVectorLoadStore(unsigned NumVectors, TTI::MaskSource Mask, VectorType *VectorTy, bool IsStore, std::optional< Instruction::CastOps > CastHint) const
virtual TargetTransformInfo::VPLegalization getVPLegalizationStrategy(const VPIntrinsic &PI) const
virtual bool enableAggressiveInterleaving(bool LoopHasReductions) const
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
virtual bool isLegalMaskedStore(Type *DataType, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind) const
virtual InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *, const SCEV *, TTI::TargetCostKind) const
virtual bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const
virtual bool isIndexedLoadLegal(TTI::MemIndexedMode Mode, Type *Ty) const
virtual unsigned adjustInliningThreshold(const CallBase *CB) const
virtual unsigned getLoadVectorFactor(unsigned VF, unsigned LoadSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
virtual bool shouldDropLSRSolutionIfLessProfitable() const
virtual bool hasVolatileVariant(Instruction *I, unsigned AddrSpace) const
virtual bool isLegalMaskedLoad(Type *DataType, Align Alignment, unsigned AddressSpace, TTI::MaskKind MaskKind) const
virtual bool hasDivRemOp(Type *DataType, bool IsSigned) const
virtual bool isLegalStridedLoadStore(Type *DataType, Align Alignment) const
virtual bool isLegalICmpImmediate(int64_t Imm) const
virtual InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo, const Instruction *I) const
virtual bool haveFastSqrt(Type *Ty) const
virtual ElementCount getMinimumVF(unsigned ElemWidth, bool IsScalable) const
virtual bool collectFlatAddressOperands(SmallVectorImpl< int > &OpIndexes, Intrinsic::ID IID) const
virtual bool addrspacesMayAlias(unsigned AS0, unsigned AS1) const
virtual unsigned getRegisterClassForType(bool Vector, Type *Ty=nullptr) const
virtual std::optional< unsigned > getVScaleForTuning() const
virtual InstructionCost getIntImmCost(const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
virtual InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, StackOffset BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const
virtual unsigned getNumberOfParts(Type *Tp) const
virtual bool isLegalMaskedCompressStore(Type *DataType, Align Alignment) const
virtual bool isHardwareLoopProfitable(Loop *L, ScalarEvolution &SE, AssumptionCache &AC, TargetLibraryInfo *LibInfo, HardwareLoopInfo &HWLoopInfo) const
virtual void getPeelingPreferences(Loop *, ScalarEvolution &, TTI::PeelingPreferences &) const
virtual std::optional< Value * > simplifyDemandedUseBitsIntrinsic(InstCombiner &IC, IntrinsicInst &II, APInt DemandedMask, KnownBits &Known, bool &KnownBitsComputed) const
virtual bool useColdCCForColdCall(Function &F) const
virtual unsigned getNumberOfRegisters(unsigned ClassID) const
virtual bool canHaveNonUndefGlobalInitializerInAddressSpace(unsigned AS) const
virtual APInt getAddrSpaceCastPreservedPtrMask(unsigned SrcAS, unsigned DstAS) const
virtual bool isLegalAddScalableImmediate(int64_t Imm) const
virtual bool isLegalInterleavedAccessType(VectorType *VTy, unsigned Factor, Align Alignment, unsigned AddrSpace) const
virtual bool preferTailFoldingOverEpilogue(TailFoldingInfo *TFI) const
TargetTransformInfoImplBase(TargetTransformInfoImplBase &&Arg)
virtual bool shouldPrefetchAddressSpace(unsigned AS) const
virtual bool forceScalarizeMaskedScatter(VectorType *DataType, Align Alignment) const
virtual uint64_t getMaxMemIntrinsicInlineSizeThreshold() const
virtual KnownBits computeKnownBitsAddrSpaceCast(unsigned FromAS, unsigned ToAS, const KnownBits &FromPtrBits) const
virtual unsigned getMinVectorRegisterBitWidth() const
unsigned minRequiredElementSize(const Value *Val, bool &isSigned) const
virtual bool shouldBuildLookupTablesForConstant(Constant *C) const
virtual bool isFPVectorizationPotentiallyUnsafe() const
virtual bool isLegalToVectorizeReduction(const RecurrenceDescriptor &RdxDesc, ElementCount VF) const
virtual InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr) const
virtual InstructionCost getIndexedVectorInstrCostFromEnd(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index) const
virtual std::optional< unsigned > getCacheSize(TargetTransformInfo::CacheLevel Level) const
virtual InstructionCost getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index, TTI::TargetCostKind CostKind) const
virtual bool shouldTreatInstructionLikeSelect(const Instruction *I) const
virtual std::optional< Instruction * > instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const
virtual unsigned getEpilogueVectorizationMinVF() const
virtual std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
virtual bool shouldMaximizeVectorBandwidth(TargetTransformInfo::RegisterKind K) const
virtual void getMemcpyLoopResidualLoweringType(SmallVectorImpl< Type * > &OpsOut, LLVMContext &Context, unsigned RemainingBytes, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicCpySize) const
virtual unsigned getStoreMinimumVF(unsigned VF, Type *, Type *, Align, unsigned) const
virtual InstructionCost getRegisterClassReloadCost(unsigned ClassID, TTI::TargetCostKind CostKind) const
virtual TTI::PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const
virtual TTI::AddressingModeKind getPreferredAddressingMode(const Loop *L, ScalarEvolution *SE) const
virtual bool forceScalarizeMaskedGather(VectorType *DataType, Align Alignment) const
virtual unsigned getMaxPrefetchIterationsAhead() const
virtual bool allowVectorElementIndexingUsingGEP() const
virtual bool isUniform(const Instruction *I, const SmallBitVector &UniformArgs) const
virtual InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind) const
virtual TTI::ReductionShuffle getPreferredExpandedReductionShuffle(const IntrinsicInst *II) const
const SCEVConstant * getConstantStrideStep(ScalarEvolution *SE, const SCEV *Ptr) const
virtual bool hasBranchDivergence(const Function *F=nullptr) const
virtual InstructionCost getArithmeticReductionCost(unsigned, VectorType *, std::optional< FastMathFlags > FMF, TTI::TargetCostKind) const
virtual bool isProfitableToHoist(Instruction *I) const
virtual const char * getRegisterClassName(unsigned ClassID) const
virtual InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *, FastMathFlags, TTI::TargetCostKind) const
virtual bool isLegalToVectorizeLoad(LoadInst *LI) const
virtual unsigned getLoadStoreVecRegBitWidth(unsigned AddrSpace) const
virtual unsigned getInlineCallPenalty(const Function *F, const CallBase &Call, unsigned DefaultCallPenalty) const
virtual unsigned getMaxInterleaveFactor(ElementCount VF, bool HasUnorderedReductions) const
virtual InstructionCost getVectorInstrCost(const Instruction &I, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual InstructionCost getAltInstrCost(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask, TTI::TargetCostKind CostKind, ArrayRef< const Value * > Scalars) const
virtual bool isVectorShiftByScalarCheap(Type *Ty) const
virtual bool isLegalNTStore(Type *DataType, Align Alignment) const
virtual APInt getFeatureMask(const Function &F) const
virtual InstructionCost getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA, TTI::TargetCostKind CostKind) const
virtual std::optional< unsigned > getMinPageSize() const
virtual bool shouldCopyAttributeWhenOutliningFrom(const Function *Caller, const Attribute &Attr) const
virtual unsigned getRegUsageForType(Type *Ty) const
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
virtual InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind, bool ForPoisonSrc=true, ArrayRef< Value * > VL={}, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual bool isElementTypeLegalForScalableVector(Type *Ty) const
virtual bool isLoweredToCall(const Function *F) const
virtual bool isLegalMaskedScatter(Type *DataType, Align Alignment) const
virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Scalar, ArrayRef< std::tuple< Value *, User *, int > > ScalarUserAndIdx, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual InstructionCost getRegisterClassSpillCost(unsigned ClassID, TTI::TargetCostKind CostKind) const
virtual bool isIndexedStoreLegal(TTI::MemIndexedMode Mode, Type *Ty) const
virtual BranchProbability getPredictableBranchThreshold() const
virtual InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind, Type *AccessType) const
virtual bool isValidAddrSpaceCast(unsigned FromAS, unsigned ToAS) const
virtual InstructionCost getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind) const
virtual bool isLegalToVectorizeStore(StoreInst *SI) const
virtual bool areInlineCompatible(const Function *Caller, const Function *Callee) const
virtual bool isTargetIntrinsicWithStructReturnOverloadAtField(Intrinsic::ID ID, int RetIdx) const
virtual bool hasConditionalLoadStoreForType(Type *Ty, bool IsStore) const
virtual bool canSaveCmp(Loop *L, CondBrInst **BI, ScalarEvolution *SE, LoopInfo *LI, DominatorTree *DT, AssumptionCache *AC, TargetLibraryInfo *LibInfo) const
virtual bool preferInLoopReduction(RecurKind Kind, Type *Ty) const
virtual bool isMultiversionedFunction(const Function &F) const
virtual InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr) const
virtual bool isNoopAddrSpaceCast(unsigned, unsigned) const
virtual bool isExpensiveToSpeculativelyExecute(const Instruction *I) const
virtual bool isLSRCostLess(const TTI::LSRCost &C1, const TTI::LSRCost &C2) const
virtual bool isLegalMaskedVectorHistogram(Type *AddrType, Type *DataType) const
virtual bool isLegalMaskedGather(Type *DataType, Align Alignment) const
virtual unsigned getEstimatedNumberOfCaseClusters(const SwitchInst &SI, unsigned &JTSize, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI) const
virtual bool isLegalAddImmediate(int64_t Imm) const
virtual InstructionCost getInsertExtractValueCost(unsigned Opcode, TTI::TargetCostKind CostKind) const
virtual InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I) const
virtual ValueUniformity getValueUniformity(const Value *V) const
virtual bool isLegalNTLoad(Type *DataType, Align Alignment) const
virtual TargetTransformInfo::VectorInstrContext getBuildVectorContextHint(ArrayRef< int > Mask, ArrayRef< Value * > Scalars, function_ref< bool(SmallVectorImpl< TargetTransformInfo::BuildVectorUseOp > &)> GatherUseOps) const
virtual InstructionCost getBranchMispredictPenalty() const
virtual bool isTargetIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx) const
virtual InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind) const
virtual InstructionCost getIntImmCodeSizeCost(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty) const
bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr, int64_t MergeDistance) const
virtual Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType, bool CanCreate=true) const
virtual bool enableMaskedInterleavedAccessVectorization() const
virtual bool isLegalSpeculativeLoad(Type *DataType, unsigned AddressSpace) const
virtual std::pair< KnownBits, KnownBits > computeKnownBitsAddrSpaceCast(unsigned ToAS, const Value &PtrOp) const
virtual Type * getMemcpyLoopLoweringType(LLVMContext &Context, Value *Length, unsigned SrcAddrSpace, unsigned DestAddrSpace, Align SrcAlign, Align DestAlign, std::optional< uint32_t > AtomicElementSize) const
virtual unsigned getInliningThresholdMultiplier() const
TargetTransformInfoImplBase(const DataLayout &DL)
virtual bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask, ArrayRef< const Value * > Scalars) const
virtual InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind) const
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
virtual bool shouldExpandReduction(const IntrinsicInst *II) const
virtual bool isLegalToVectorizeStoreChain(unsigned ChainSizeInBytes, Align Alignment, unsigned AddrSpace) const
virtual unsigned getGISelRematGlobalCost() const
virtual InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond, bool UseMaskForGaps) const
virtual bool isTypeLegal(Type *Ty) const
virtual unsigned getAssumedAddrSpace(const Value *V) const
virtual bool allowsMisalignedMemoryAccesses(LLVMContext &Context, unsigned BitWidth, unsigned AddressSpace, Align Alignment, unsigned *Fast) const
virtual unsigned getStoreVectorFactor(unsigned VF, unsigned StoreSize, unsigned ChainSizeInBytes, VectorType *VecTy) const
virtual InstructionCost getExtendedReductionCost(unsigned Opcode, bool IsUnsigned, Type *ResTy, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind) const
virtual unsigned getInliningCostBenefitAnalysisSavingsMultiplier() const
virtual bool areTypesABICompatible(const Function *Caller, const Function *Callee, ArrayRef< Type * > Types) const
virtual unsigned getNumBytesToPadGlobalArray(unsigned Size, Type *ArrayType) const
virtual bool preferToKeepConstantsAttached(const Instruction &Inst, const Function &Fn) const
virtual bool isFCmpOrdCheaperThanFCmpZero(Type *Ty) const
virtual bool supportsTailCallFor(const CallBase *CB) const
virtual bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader) const
virtual InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, const TTI::TargetCostKind CostKind) const
virtual InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *DstTy, VectorType *SrcTy, TTI::TargetCostKind CostKind, ArrayRef< int > Mask, int Index, VectorType *SubTp, ArrayRef< const Value * > Args={}, const Instruction *CtxI=nullptr, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, const Value *Op0, const Value *Op1, TTI::VectorInstrContext VIC=TTI::VectorInstrContext::None) const
virtual bool isTargetIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx) const
virtual bool shouldConsiderVectorizationRegPressure() const
virtual InstructionCost getMemcpyCost(const Instruction *I) const
virtual unsigned getInliningCostBenefitAnalysisProfitableMultiplier() const
virtual bool useFastCCForInternalCall(Function &F) const
virtual bool preferEpilogueVectorization(ElementCount Iters) const
virtual void getUnrollingPreferences(Loop *, ScalarEvolution &, TTI::UnrollingPreferences &, OptimizationRemarkEmitter *) const
TargetTransformInfoImplBase(const TargetTransformInfoImplBase &Arg)=default
virtual bool isProfitableToSinkOperands(Instruction *I, SmallVectorImpl< Use * > &Ops) const
virtual bool supportsEfficientVectorElementLoadStore() const
virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
virtual APInt getPriorityMask(const Function &F) const
virtual unsigned getMinTripCountTailFoldingThreshold() const
virtual TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
virtual void collectKernelLaunchBounds(const Function &F, SmallVectorImpl< std::pair< StringRef, int64_t > > &LB) const
bool supportsTailCallFor(const CallBase *CB) const override
bool isExpensiveToSpeculativelyExecute(const Instruction *I) const override
InstructionCost getInstructionCost(const User *U, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind) const override
InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, TTI::TargetCostKind CostKind) const override
InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, TTI::TargetCostKind CostKind, Type *AccessType) const override
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.
MaskSource
Enum describing the source/producer of a mask.
PopcntSupportKind
Flags indicating the kind of support for population count.
llvm::VectorInstrContext VectorInstrContext
@ 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.
static LLVM_ABI VectorInstrContext getVectorInstrContextHint(const Instruction *I)
Calculates a VectorInstrContext from I.
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 get(ScalarTy Quantity, bool Scalable)
Definition TypeSize.h:336
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
bool isVectorTy() const
True if this is an instance of VectorType.
Definition Type.h:283
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
Definition Type.cpp:297
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:222
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Definition Type.h:280
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Definition Type.cpp:303
This is the common base class for vector predication intrinsics.
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:712
Base class of all SIMD vector types.
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:200
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition TypeSize.h:168
An efficient, type-erasing, non-owning reference to a callable.
CallInst * Call
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
match_combine_or< Ty... > m_CombineOr(const Ty &...Ps)
Combine pattern matchers matching any of Ps patterns.
LogicalOp_match< LHS, RHS, Instruction::And > m_LogicalAnd(const LHS &L, const RHS &R)
Matches L && R either in the form of L & R or L ?
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_Value()
Match an arbitrary value and ignore it.
auto m_Constant()
Match an arbitrary Constant and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
LogicalOp_match< LHS, RHS, Instruction::Or > m_LogicalOr(const LHS &L, const RHS &R)
Matches L || R either in the form of L | R or L ?
This is an optimization pass for GlobalISel generic memory operations.
@ Length
Definition DWP.cpp:577
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
InstructionCost Cost
@ Known
Known to have no common set bits.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
Definition STLExtras.h:2570
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition MathExtras.h:285
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.
Definition STLExtras.h:1762
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
constexpr int PoisonMaskElem
RecurKind
These are the kinds of recurrences that we support.
@ Fast
Assign the register banks as fast as possible (default).
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
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...
ValueUniformity
Enum describing how values behave with respect to uniformity and divergence, to answer the question: ...
Definition Uniformity.h:18
@ Default
The result value is uniform if and only if all operands are uniform.
Definition Uniformity.h:20
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Attributes of a target dependent hardware loop.
KnownBits anyextOrTrunc(unsigned BitWidth) const
Return known bits for an "any" extension or truncation of the value we're tracking.
Definition KnownBits.h:190
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.