LLVM  10.0.0
AArch64TargetTransformInfo.cpp
Go to the documentation of this file.
1 //===-- AArch64TargetTransformInfo.cpp - AArch64 specific TTI -------------===//
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 
9 #include "AArch64ExpandImm.h"
12 #include "llvm/Analysis/LoopInfo.h"
15 #include "llvm/CodeGen/CostTable.h"
17 #include "llvm/IR/IntrinsicInst.h"
18 #include "llvm/IR/IntrinsicsAArch64.h"
19 #include "llvm/Support/Debug.h"
20 #include <algorithm>
21 using namespace llvm;
22 
23 #define DEBUG_TYPE "aarch64tti"
24 
25 static cl::opt<bool> EnableFalkorHWPFUnrollFix("enable-falkor-hwpf-unroll-fix",
26  cl::init(true), cl::Hidden);
27 
29  const Function *Callee) const {
30  const TargetMachine &TM = getTLI()->getTargetMachine();
31 
32  const FeatureBitset &CallerBits =
33  TM.getSubtargetImpl(*Caller)->getFeatureBits();
34  const FeatureBitset &CalleeBits =
35  TM.getSubtargetImpl(*Callee)->getFeatureBits();
36 
37  // Inline a callee if its target-features are a subset of the callers
38  // target-features.
39  return (CallerBits & CalleeBits) == CalleeBits;
40 }
41 
42 /// Calculate the cost of materializing a 64-bit value. This helper
43 /// method might only calculate a fraction of a larger immediate. Therefore it
44 /// is valid to return a cost of ZERO.
46  // Check if the immediate can be encoded within an instruction.
47  if (Val == 0 || AArch64_AM::isLogicalImmediate(Val, 64))
48  return 0;
49 
50  if (Val < 0)
51  Val = ~Val;
52 
53  // Calculate how many moves we will need to materialize this constant.
55  AArch64_IMM::expandMOVImm(Val, 64, Insn);
56  return Insn.size();
57 }
58 
59 /// Calculate the cost of materializing the given constant.
61  assert(Ty->isIntegerTy());
62 
63  unsigned BitSize = Ty->getPrimitiveSizeInBits();
64  if (BitSize == 0)
65  return ~0U;
66 
67  // Sign-extend all constants to a multiple of 64-bit.
68  APInt ImmVal = Imm;
69  if (BitSize & 0x3f)
70  ImmVal = Imm.sext((BitSize + 63) & ~0x3fU);
71 
72  // Split the constant into 64-bit chunks and calculate the cost for each
73  // chunk.
74  int Cost = 0;
75  for (unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) {
76  APInt Tmp = ImmVal.ashr(ShiftVal).sextOrTrunc(64);
77  int64_t Val = Tmp.getSExtValue();
78  Cost += getIntImmCost(Val);
79  }
80  // We need at least one instruction to materialze the constant.
81  return std::max(1, Cost);
82 }
83 
84 int AArch64TTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
85  const APInt &Imm, Type *Ty) {
86  assert(Ty->isIntegerTy());
87 
88  unsigned BitSize = Ty->getPrimitiveSizeInBits();
89  // There is no cost model for constants with a bit size of 0. Return TCC_Free
90  // here, so that constant hoisting will ignore this constant.
91  if (BitSize == 0)
92  return TTI::TCC_Free;
93 
94  unsigned ImmIdx = ~0U;
95  switch (Opcode) {
96  default:
97  return TTI::TCC_Free;
98  case Instruction::GetElementPtr:
99  // Always hoist the base address of a GetElementPtr.
100  if (Idx == 0)
101  return 2 * TTI::TCC_Basic;
102  return TTI::TCC_Free;
103  case Instruction::Store:
104  ImmIdx = 0;
105  break;
106  case Instruction::Add:
107  case Instruction::Sub:
108  case Instruction::Mul:
109  case Instruction::UDiv:
110  case Instruction::SDiv:
111  case Instruction::URem:
112  case Instruction::SRem:
113  case Instruction::And:
114  case Instruction::Or:
115  case Instruction::Xor:
116  case Instruction::ICmp:
117  ImmIdx = 1;
118  break;
119  // Always return TCC_Free for the shift value of a shift instruction.
120  case Instruction::Shl:
121  case Instruction::LShr:
122  case Instruction::AShr:
123  if (Idx == 1)
124  return TTI::TCC_Free;
125  break;
126  case Instruction::Trunc:
127  case Instruction::ZExt:
128  case Instruction::SExt:
129  case Instruction::IntToPtr:
130  case Instruction::PtrToInt:
131  case Instruction::BitCast:
132  case Instruction::PHI:
133  case Instruction::Call:
134  case Instruction::Select:
135  case Instruction::Ret:
136  case Instruction::Load:
137  break;
138  }
139 
140  if (Idx == ImmIdx) {
141  int NumConstants = (BitSize + 63) / 64;
142  int Cost = AArch64TTIImpl::getIntImmCost(Imm, Ty);
143  return (Cost <= NumConstants * TTI::TCC_Basic)
144  ? static_cast<int>(TTI::TCC_Free)
145  : Cost;
146  }
147  return AArch64TTIImpl::getIntImmCost(Imm, Ty);
148 }
149 
151  const APInt &Imm, Type *Ty) {
152  assert(Ty->isIntegerTy());
153 
154  unsigned BitSize = Ty->getPrimitiveSizeInBits();
155  // There is no cost model for constants with a bit size of 0. Return TCC_Free
156  // here, so that constant hoisting will ignore this constant.
157  if (BitSize == 0)
158  return TTI::TCC_Free;
159 
160  // Most (all?) AArch64 intrinsics do not support folding immediates into the
161  // selected instruction, so we compute the materialization cost for the
162  // immediate directly.
163  if (IID >= Intrinsic::aarch64_addg && IID <= Intrinsic::aarch64_udiv)
164  return AArch64TTIImpl::getIntImmCost(Imm, Ty);
165 
166  switch (IID) {
167  default:
168  return TTI::TCC_Free;
169  case Intrinsic::sadd_with_overflow:
170  case Intrinsic::uadd_with_overflow:
171  case Intrinsic::ssub_with_overflow:
172  case Intrinsic::usub_with_overflow:
173  case Intrinsic::smul_with_overflow:
174  case Intrinsic::umul_with_overflow:
175  if (Idx == 1) {
176  int NumConstants = (BitSize + 63) / 64;
177  int Cost = AArch64TTIImpl::getIntImmCost(Imm, Ty);
178  return (Cost <= NumConstants * TTI::TCC_Basic)
179  ? static_cast<int>(TTI::TCC_Free)
180  : Cost;
181  }
182  break;
183  case Intrinsic::experimental_stackmap:
184  if ((Idx < 2) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
185  return TTI::TCC_Free;
186  break;
187  case Intrinsic::experimental_patchpoint_void:
188  case Intrinsic::experimental_patchpoint_i64:
189  if ((Idx < 4) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
190  return TTI::TCC_Free;
191  break;
192  }
193  return AArch64TTIImpl::getIntImmCost(Imm, Ty);
194 }
195 
198  assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2");
199  if (TyWidth == 32 || TyWidth == 64)
200  return TTI::PSK_FastHardware;
201  // TODO: AArch64TargetLowering::LowerCTPOP() supports 128bit popcount.
202  return TTI::PSK_Software;
203 }
204 
205 bool AArch64TTIImpl::isWideningInstruction(Type *DstTy, unsigned Opcode,
207 
208  // A helper that returns a vector type from the given type. The number of
209  // elements in type Ty determine the vector width.
210  auto toVectorTy = [&](Type *ArgTy) {
211  return VectorType::get(ArgTy->getScalarType(),
212  DstTy->getVectorNumElements());
213  };
214 
215  // Exit early if DstTy is not a vector type whose elements are at least
216  // 16-bits wide.
217  if (!DstTy->isVectorTy() || DstTy->getScalarSizeInBits() < 16)
218  return false;
219 
220  // Determine if the operation has a widening variant. We consider both the
221  // "long" (e.g., usubl) and "wide" (e.g., usubw) versions of the
222  // instructions.
223  //
224  // TODO: Add additional widening operations (e.g., mul, shl, etc.) once we
225  // verify that their extending operands are eliminated during code
226  // generation.
227  switch (Opcode) {
228  case Instruction::Add: // UADDL(2), SADDL(2), UADDW(2), SADDW(2).
229  case Instruction::Sub: // USUBL(2), SSUBL(2), USUBW(2), SSUBW(2).
230  break;
231  default:
232  return false;
233  }
234 
235  // To be a widening instruction (either the "wide" or "long" versions), the
236  // second operand must be a sign- or zero extend having a single user. We
237  // only consider extends having a single user because they may otherwise not
238  // be eliminated.
239  if (Args.size() != 2 ||
240  (!isa<SExtInst>(Args[1]) && !isa<ZExtInst>(Args[1])) ||
241  !Args[1]->hasOneUse())
242  return false;
243  auto *Extend = cast<CastInst>(Args[1]);
244 
245  // Legalize the destination type and ensure it can be used in a widening
246  // operation.
247  auto DstTyL = TLI->getTypeLegalizationCost(DL, DstTy);
248  unsigned DstElTySize = DstTyL.second.getScalarSizeInBits();
249  if (!DstTyL.second.isVector() || DstElTySize != DstTy->getScalarSizeInBits())
250  return false;
251 
252  // Legalize the source type and ensure it can be used in a widening
253  // operation.
254  Type *SrcTy = toVectorTy(Extend->getSrcTy());
255  auto SrcTyL = TLI->getTypeLegalizationCost(DL, SrcTy);
256  unsigned SrcElTySize = SrcTyL.second.getScalarSizeInBits();
257  if (!SrcTyL.second.isVector() || SrcElTySize != SrcTy->getScalarSizeInBits())
258  return false;
259 
260  // Get the total number of vector elements in the legalized types.
261  unsigned NumDstEls = DstTyL.first * DstTyL.second.getVectorNumElements();
262  unsigned NumSrcEls = SrcTyL.first * SrcTyL.second.getVectorNumElements();
263 
264  // Return true if the legalized types have the same number of vector elements
265  // and the destination element type size is twice that of the source type.
266  return NumDstEls == NumSrcEls && 2 * SrcElTySize == DstElTySize;
267 }
268 
269 int AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
270  const Instruction *I) {
271  int ISD = TLI->InstructionOpcodeToISD(Opcode);
272  assert(ISD && "Invalid opcode");
273 
274  // If the cast is observable, and it is used by a widening instruction (e.g.,
275  // uaddl, saddw, etc.), it may be free.
276  if (I && I->hasOneUse()) {
277  auto *SingleUser = cast<Instruction>(*I->user_begin());
278  SmallVector<const Value *, 4> Operands(SingleUser->operand_values());
279  if (isWideningInstruction(Dst, SingleUser->getOpcode(), Operands)) {
280  // If the cast is the second operand, it is free. We will generate either
281  // a "wide" or "long" version of the widening instruction.
282  if (I == SingleUser->getOperand(1))
283  return 0;
284  // If the cast is not the second operand, it will be free if it looks the
285  // same as the second operand. In this case, we will generate a "long"
286  // version of the widening instruction.
287  if (auto *Cast = dyn_cast<CastInst>(SingleUser->getOperand(1)))
288  if (I->getOpcode() == unsigned(Cast->getOpcode()) &&
289  cast<CastInst>(I)->getSrcTy() == Cast->getSrcTy())
290  return 0;
291  }
292  }
293 
294  EVT SrcTy = TLI->getValueType(DL, Src);
295  EVT DstTy = TLI->getValueType(DL, Dst);
296 
297  if (!SrcTy.isSimple() || !DstTy.isSimple())
298  return BaseT::getCastInstrCost(Opcode, Dst, Src);
299 
300  static const TypeConversionCostTblEntry
301  ConversionTbl[] = {
306 
307  // The number of shll instructions for the extension.
324 
325  // LowerVectorINT_TO_FP:
332 
333  // Complex: to v2f32
340 
341  // Complex: to v4f32
346 
347  // Complex: to v8f32
352 
353  // Complex: to v16f32
356 
357  // Complex: to v2f64
364 
365 
366  // LowerVectorFP_TO_INT
373 
374  // Complex, from v2f32: legal type is v2i32 (no cost) or v2i64 (1 ext).
381 
382  // Complex, from v4f32: legal type is v4i16, 1 narrowing => ~2
387 
388  // Complex, from v2f64: legal type is v2i32, 1 narrowing => ~2.
395  };
396 
397  if (const auto *Entry = ConvertCostTableLookup(ConversionTbl, ISD,
398  DstTy.getSimpleVT(),
399  SrcTy.getSimpleVT()))
400  return Entry->Cost;
401 
402  return BaseT::getCastInstrCost(Opcode, Dst, Src);
403 }
404 
406  VectorType *VecTy,
407  unsigned Index) {
408 
409  // Make sure we were given a valid extend opcode.
410  assert((Opcode == Instruction::SExt || Opcode == Instruction::ZExt) &&
411  "Invalid opcode");
412 
413  // We are extending an element we extract from a vector, so the source type
414  // of the extend is the element type of the vector.
415  auto *Src = VecTy->getElementType();
416 
417  // Sign- and zero-extends are for integer types only.
418  assert(isa<IntegerType>(Dst) && isa<IntegerType>(Src) && "Invalid type");
419 
420  // Get the cost for the extract. We compute the cost (if any) for the extend
421  // below.
422  auto Cost = getVectorInstrCost(Instruction::ExtractElement, VecTy, Index);
423 
424  // Legalize the types.
425  auto VecLT = TLI->getTypeLegalizationCost(DL, VecTy);
426  auto DstVT = TLI->getValueType(DL, Dst);
427  auto SrcVT = TLI->getValueType(DL, Src);
428 
429  // If the resulting type is still a vector and the destination type is legal,
430  // we may get the extension for free. If not, get the default cost for the
431  // extend.
432  if (!VecLT.second.isVector() || !TLI->isTypeLegal(DstVT))
433  return Cost + getCastInstrCost(Opcode, Dst, Src);
434 
435  // The destination type should be larger than the element type. If not, get
436  // the default cost for the extend.
437  if (DstVT.getSizeInBits() < SrcVT.getSizeInBits())
438  return Cost + getCastInstrCost(Opcode, Dst, Src);
439 
440  switch (Opcode) {
441  default:
442  llvm_unreachable("Opcode should be either SExt or ZExt");
443 
444  // For sign-extends, we only need a smov, which performs the extension
445  // automatically.
446  case Instruction::SExt:
447  return Cost;
448 
449  // For zero-extends, the extend is performed automatically by a umov unless
450  // the destination type is i64 and the element type is i8 or i16.
451  case Instruction::ZExt:
452  if (DstVT.getSizeInBits() != 64u || SrcVT.getSizeInBits() == 32u)
453  return Cost;
454  }
455 
456  // If we are unable to perform the extend for free, get the default cost.
457  return Cost + getCastInstrCost(Opcode, Dst, Src);
458 }
459 
460 int AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val,
461  unsigned Index) {
462  assert(Val->isVectorTy() && "This must be a vector type");
463 
464  if (Index != -1U) {
465  // Legalize the type.
466  std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Val);
467 
468  // This type is legalized to a scalar type.
469  if (!LT.second.isVector())
470  return 0;
471 
472  // The type may be split. Normalize the index to the new type.
473  unsigned Width = LT.second.getVectorNumElements();
474  Index = Index % Width;
475 
476  // The element at index zero is already inside the vector.
477  if (Index == 0)
478  return 0;
479  }
480 
481  // All other insert/extracts cost this much.
482  return ST->getVectorInsertExtractBaseCost();
483 }
484 
486  unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info,
487  TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo,
489  const Instruction *CxtI) {
490  // Legalize the type.
491  std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Ty);
492 
493  // If the instruction is a widening instruction (e.g., uaddl, saddw, etc.),
494  // add in the widening overhead specified by the sub-target. Since the
495  // extends feeding widening instructions are performed automatically, they
496  // aren't present in the generated code and have a zero cost. By adding a
497  // widening overhead here, we attach the total cost of the combined operation
498  // to the widening instruction.
499  int Cost = 0;
500  if (isWideningInstruction(Ty, Opcode, Args))
501  Cost += ST->getWideningBaseCost();
502 
503  int ISD = TLI->InstructionOpcodeToISD(Opcode);
504 
505  switch (ISD) {
506  default:
507  return Cost + BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
508  Opd1PropInfo, Opd2PropInfo);
509  case ISD::SDIV:
511  Opd2PropInfo == TargetTransformInfo::OP_PowerOf2) {
512  // On AArch64, scalar signed division by constants power-of-two are
513  // normally expanded to the sequence ADD + CMP + SELECT + SRA.
514  // The OperandValue properties many not be same as that of previous
515  // operation; conservatively assume OP_None.
516  Cost += getArithmeticInstrCost(Instruction::Add, Ty, Opd1Info, Opd2Info,
519  Cost += getArithmeticInstrCost(Instruction::Sub, Ty, Opd1Info, Opd2Info,
522  Cost += getArithmeticInstrCost(Instruction::Select, Ty, Opd1Info, Opd2Info,
525  Cost += getArithmeticInstrCost(Instruction::AShr, Ty, Opd1Info, Opd2Info,
528  return Cost;
529  }
531  case ISD::UDIV:
533  auto VT = TLI->getValueType(DL, Ty);
534  if (TLI->isOperationLegalOrCustom(ISD::MULHU, VT)) {
535  // Vector signed division by constant are expanded to the
536  // sequence MULHS + ADD/SUB + SRA + SRL + ADD, and unsigned division
537  // to MULHS + SUB + SRL + ADD + SRL.
538  int MulCost = getArithmeticInstrCost(Instruction::Mul, Ty, Opd1Info,
539  Opd2Info,
542  int AddCost = getArithmeticInstrCost(Instruction::Add, Ty, Opd1Info,
543  Opd2Info,
546  int ShrCost = getArithmeticInstrCost(Instruction::AShr, Ty, Opd1Info,
547  Opd2Info,
550  return MulCost * 2 + AddCost * 2 + ShrCost * 2 + 1;
551  }
552  }
553 
554  Cost += BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info,
555  Opd1PropInfo, Opd2PropInfo);
556  if (Ty->isVectorTy()) {
557  // On AArch64, vector divisions are not supported natively and are
558  // expanded into scalar divisions of each pair of elements.
559  Cost += getArithmeticInstrCost(Instruction::ExtractElement, Ty, Opd1Info,
560  Opd2Info, Opd1PropInfo, Opd2PropInfo);
561  Cost += getArithmeticInstrCost(Instruction::InsertElement, Ty, Opd1Info,
562  Opd2Info, Opd1PropInfo, Opd2PropInfo);
563  // TODO: if one of the arguments is scalar, then it's not necessary to
564  // double the cost of handling the vector elements.
565  Cost += Cost;
566  }
567  return Cost;
568 
569  case ISD::ADD:
570  case ISD::MUL:
571  case ISD::XOR:
572  case ISD::OR:
573  case ISD::AND:
574  // These nodes are marked as 'custom' for combining purposes only.
575  // We know that they are legal. See LowerAdd in ISelLowering.
576  return (Cost + 1) * LT.first;
577  }
578 }
579 
581  const SCEV *Ptr) {
582  // Address computations in vectorized code with non-consecutive addresses will
583  // likely result in more instructions compared to scalar code where the
584  // computation can more often be merged into the index mode. The resulting
585  // extra micro-ops can significantly decrease throughput.
586  unsigned NumVectorInstToHideOverhead = 10;
587  int MaxMergeDistance = 64;
588 
589  if (Ty->isVectorTy() && SE &&
590  !BaseT::isConstantStridedAccessLessThan(SE, Ptr, MaxMergeDistance + 1))
591  return NumVectorInstToHideOverhead;
592 
593  // In many cases the address computation is not merged into the instruction
594  // addressing mode.
595  return 1;
596 }
597 
598 int AArch64TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy,
599  Type *CondTy, const Instruction *I) {
600 
601  int ISD = TLI->InstructionOpcodeToISD(Opcode);
602  // We don't lower some vector selects well that are wider than the register
603  // width.
604  if (ValTy->isVectorTy() && ISD == ISD::SELECT) {
605  // We would need this many instructions to hide the scalarization happening.
606  const int AmortizationCost = 20;
607  static const TypeConversionCostTblEntry
608  VectorSelectTbl[] = {
612  { ISD::SELECT, MVT::v4i1, MVT::v4i64, 4 * AmortizationCost },
613  { ISD::SELECT, MVT::v8i1, MVT::v8i64, 8 * AmortizationCost },
614  { ISD::SELECT, MVT::v16i1, MVT::v16i64, 16 * AmortizationCost }
615  };
616 
617  EVT SelCondTy = TLI->getValueType(DL, CondTy);
618  EVT SelValTy = TLI->getValueType(DL, ValTy);
619  if (SelCondTy.isSimple() && SelValTy.isSimple()) {
620  if (const auto *Entry = ConvertCostTableLookup(VectorSelectTbl, ISD,
621  SelCondTy.getSimpleVT(),
622  SelValTy.getSimpleVT()))
623  return Entry->Cost;
624  }
625  }
626  return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, I);
627 }
628 
630 AArch64TTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
633  Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
634  Options.NumLoadsPerBlock = Options.MaxNumLoads;
635  // TODO: Though vector loads usually perform well on AArch64, in some targets
636  // they may wake up the FP unit, which raises the power consumption. Perhaps
637  // they could be used with no holds barred (-O3).
638  Options.LoadSizes = {8, 4, 2, 1};
639  return Options;
640 }
641 
642 int AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Ty,
643  MaybeAlign Alignment, unsigned AddressSpace,
644  const Instruction *I) {
645  auto LT = TLI->getTypeLegalizationCost(DL, Ty);
646 
647  if (ST->isMisaligned128StoreSlow() && Opcode == Instruction::Store &&
648  LT.second.is128BitVector() && (!Alignment || *Alignment < Align(16))) {
649  // Unaligned stores are extremely inefficient. We don't split all
650  // unaligned 128-bit stores because the negative impact that has shown in
651  // practice on inlined block copy code.
652  // We make such stores expensive so that we will only vectorize if there
653  // are 6 other instructions getting vectorized.
654  const int AmortizationCost = 6;
655 
656  return LT.first * 2 * AmortizationCost;
657  }
658 
659  if (Ty->isVectorTy() && Ty->getVectorElementType()->isIntegerTy(8)) {
660  unsigned ProfitableNumElements;
661  if (Opcode == Instruction::Store)
662  // We use a custom trunc store lowering so v.4b should be profitable.
663  ProfitableNumElements = 4;
664  else
665  // We scalarize the loads because there is not v.4b register and we
666  // have to promote the elements to v.2.
667  ProfitableNumElements = 8;
668 
669  if (Ty->getVectorNumElements() < ProfitableNumElements) {
670  unsigned NumVecElts = Ty->getVectorNumElements();
671  unsigned NumVectorizableInstsToAmortize = NumVecElts * 2;
672  // We generate 2 instructions per vector element.
673  return NumVectorizableInstsToAmortize * NumVecElts * 2;
674  }
675  }
676 
677  return LT.first;
678 }
679 
681  unsigned Factor,
682  ArrayRef<unsigned> Indices,
683  unsigned Alignment,
684  unsigned AddressSpace,
685  bool UseMaskForCond,
686  bool UseMaskForGaps) {
687  assert(Factor >= 2 && "Invalid interleave factor");
688  assert(isa<VectorType>(VecTy) && "Expect a vector type");
689 
690  if (!UseMaskForCond && !UseMaskForGaps &&
691  Factor <= TLI->getMaxSupportedInterleaveFactor()) {
692  unsigned NumElts = VecTy->getVectorNumElements();
693  auto *SubVecTy = VectorType::get(VecTy->getScalarType(), NumElts / Factor);
694 
695  // ldN/stN only support legal vector types of size 64 or 128 in bits.
696  // Accesses having vector types that are a multiple of 128 bits can be
697  // matched to more than one ldN/stN instruction.
698  if (NumElts % Factor == 0 &&
699  TLI->isLegalInterleavedAccessType(SubVecTy, DL))
700  return Factor * TLI->getNumInterleavedAccesses(SubVecTy, DL);
701  }
702 
703  return BaseT::getInterleavedMemoryOpCost(Opcode, VecTy, Factor, Indices,
704  Alignment, AddressSpace,
705  UseMaskForCond, UseMaskForGaps);
706 }
707 
709  int Cost = 0;
710  for (auto *I : Tys) {
711  if (!I->isVectorTy())
712  continue;
713  if (I->getScalarSizeInBits() * I->getVectorNumElements() == 128)
714  Cost += getMemoryOpCost(Instruction::Store, I, Align(128), 0) +
716  }
717  return Cost;
718 }
719 
721  return ST->getMaxInterleaveFactor();
722 }
723 
724 // For Falkor, we want to avoid having too many strided loads in a loop since
725 // that can exhaust the HW prefetcher resources. We adjust the unroller
726 // MaxCount preference below to attempt to ensure unrolling doesn't create too
727 // many strided loads.
728 static void
731  enum { MaxStridedLoads = 7 };
732  auto countStridedLoads = [](Loop *L, ScalarEvolution &SE) {
733  int StridedLoads = 0;
734  // FIXME? We could make this more precise by looking at the CFG and
735  // e.g. not counting loads in each side of an if-then-else diamond.
736  for (const auto BB : L->blocks()) {
737  for (auto &I : *BB) {
738  LoadInst *LMemI = dyn_cast<LoadInst>(&I);
739  if (!LMemI)
740  continue;
741 
742  Value *PtrValue = LMemI->getPointerOperand();
743  if (L->isLoopInvariant(PtrValue))
744  continue;
745 
746  const SCEV *LSCEV = SE.getSCEV(PtrValue);
747  const SCEVAddRecExpr *LSCEVAddRec = dyn_cast<SCEVAddRecExpr>(LSCEV);
748  if (!LSCEVAddRec || !LSCEVAddRec->isAffine())
749  continue;
750 
751  // FIXME? We could take pairing of unrolled load copies into account
752  // by looking at the AddRec, but we would probably have to limit this
753  // to loops with no stores or other memory optimization barriers.
754  ++StridedLoads;
755  // We've seen enough strided loads that seeing more won't make a
756  // difference.
757  if (StridedLoads > MaxStridedLoads / 2)
758  return StridedLoads;
759  }
760  }
761  return StridedLoads;
762  };
763 
764  int StridedLoads = countStridedLoads(L, SE);
765  LLVM_DEBUG(dbgs() << "falkor-hwpf: detected " << StridedLoads
766  << " strided loads\n");
767  // Pick the largest power of 2 unroll count that won't result in too many
768  // strided loads.
769  if (StridedLoads) {
770  UP.MaxCount = 1 << Log2_32(MaxStridedLoads / StridedLoads);
771  LLVM_DEBUG(dbgs() << "falkor-hwpf: setting unroll MaxCount to "
772  << UP.MaxCount << '\n');
773  }
774 }
775 
778  // Enable partial unrolling and runtime unrolling.
780 
781  // For inner loop, it is more likely to be a hot one, and the runtime check
782  // can be promoted out from LICM pass, so the overhead is less, let's try
783  // a larger threshold to unroll more loops.
784  if (L->getLoopDepth() > 1)
785  UP.PartialThreshold *= 2;
786 
787  // Disable partial & runtime unrolling on -Os.
789 
793 }
794 
796  Type *ExpectedType) {
797  switch (Inst->getIntrinsicID()) {
798  default:
799  return nullptr;
800  case Intrinsic::aarch64_neon_st2:
801  case Intrinsic::aarch64_neon_st3:
802  case Intrinsic::aarch64_neon_st4: {
803  // Create a struct type
804  StructType *ST = dyn_cast<StructType>(ExpectedType);
805  if (!ST)
806  return nullptr;
807  unsigned NumElts = Inst->getNumArgOperands() - 1;
808  if (ST->getNumElements() != NumElts)
809  return nullptr;
810  for (unsigned i = 0, e = NumElts; i != e; ++i) {
811  if (Inst->getArgOperand(i)->getType() != ST->getElementType(i))
812  return nullptr;
813  }
814  Value *Res = UndefValue::get(ExpectedType);
815  IRBuilder<> Builder(Inst);
816  for (unsigned i = 0, e = NumElts; i != e; ++i) {
817  Value *L = Inst->getArgOperand(i);
818  Res = Builder.CreateInsertValue(Res, L, i);
819  }
820  return Res;
821  }
822  case Intrinsic::aarch64_neon_ld2:
823  case Intrinsic::aarch64_neon_ld3:
824  case Intrinsic::aarch64_neon_ld4:
825  if (Inst->getType() == ExpectedType)
826  return Inst;
827  return nullptr;
828  }
829 }
830 
833  switch (Inst->getIntrinsicID()) {
834  default:
835  break;
836  case Intrinsic::aarch64_neon_ld2:
837  case Intrinsic::aarch64_neon_ld3:
838  case Intrinsic::aarch64_neon_ld4:
839  Info.ReadMem = true;
840  Info.WriteMem = false;
841  Info.PtrVal = Inst->getArgOperand(0);
842  break;
843  case Intrinsic::aarch64_neon_st2:
844  case Intrinsic::aarch64_neon_st3:
845  case Intrinsic::aarch64_neon_st4:
846  Info.ReadMem = false;
847  Info.WriteMem = true;
848  Info.PtrVal = Inst->getArgOperand(Inst->getNumArgOperands() - 1);
849  break;
850  }
851 
852  switch (Inst->getIntrinsicID()) {
853  default:
854  return false;
855  case Intrinsic::aarch64_neon_ld2:
856  case Intrinsic::aarch64_neon_st2:
857  Info.MatchingId = VECTOR_LDST_TWO_ELEMENTS;
858  break;
859  case Intrinsic::aarch64_neon_ld3:
860  case Intrinsic::aarch64_neon_st3:
861  Info.MatchingId = VECTOR_LDST_THREE_ELEMENTS;
862  break;
863  case Intrinsic::aarch64_neon_ld4:
864  case Intrinsic::aarch64_neon_st4:
865  Info.MatchingId = VECTOR_LDST_FOUR_ELEMENTS;
866  break;
867  }
868  return true;
869 }
870 
871 /// See if \p I should be considered for address type promotion. We check if \p
872 /// I is a sext with right type and used in memory accesses. If it used in a
873 /// "complex" getelementptr, we allow it to be promoted without finding other
874 /// sext instructions that sign extended the same initial value. A getelementptr
875 /// is considered as "complex" if it has more than 2 operands.
877  const Instruction &I, bool &AllowPromotionWithoutCommonHeader) {
878  bool Considerable = false;
879  AllowPromotionWithoutCommonHeader = false;
880  if (!isa<SExtInst>(&I))
881  return false;
882  Type *ConsideredSExtType =
884  if (I.getType() != ConsideredSExtType)
885  return false;
886  // See if the sext is the one with the right type and used in at least one
887  // GetElementPtrInst.
888  for (const User *U : I.users()) {
889  if (const GetElementPtrInst *GEPInst = dyn_cast<GetElementPtrInst>(U)) {
890  Considerable = true;
891  // A getelementptr is considered as "complex" if it has more than 2
892  // operands. We will promote a SExt used in such complex GEP as we
893  // expect some computation to be merged if they are done on 64 bits.
894  if (GEPInst->getNumOperands() > 2) {
895  AllowPromotionWithoutCommonHeader = true;
896  break;
897  }
898  }
899  }
900  return Considerable;
901 }
902 
903 bool AArch64TTIImpl::useReductionIntrinsic(unsigned Opcode, Type *Ty,
904  TTI::ReductionFlags Flags) const {
905  assert(isa<VectorType>(Ty) && "Expected Ty to be a vector type");
906  unsigned ScalarBits = Ty->getScalarSizeInBits();
907  switch (Opcode) {
908  case Instruction::FAdd:
909  case Instruction::FMul:
910  case Instruction::And:
911  case Instruction::Or:
912  case Instruction::Xor:
913  case Instruction::Mul:
914  return false;
915  case Instruction::Add:
916  return ScalarBits * Ty->getVectorNumElements() >= 128;
917  case Instruction::ICmp:
918  return (ScalarBits < 64) &&
919  (ScalarBits * Ty->getVectorNumElements() >= 128);
920  case Instruction::FCmp:
921  return Flags.NoNaN;
922  default:
923  llvm_unreachable("Unhandled reduction opcode");
924  }
925  return false;
926 }
927 
929  bool IsPairwiseForm) {
930 
931  if (IsPairwiseForm)
932  return BaseT::getArithmeticReductionCost(Opcode, ValTy, IsPairwiseForm);
933 
934  std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy);
935  MVT MTy = LT.second;
936  int ISD = TLI->InstructionOpcodeToISD(Opcode);
937  assert(ISD && "Invalid opcode");
938 
939  // Horizontal adds can use the 'addv' instruction. We model the cost of these
940  // instructions as normal vector adds. This is the only arithmetic vector
941  // reduction operation for which we have an instruction.
942  static const CostTblEntry CostTblNoPairwise[]{
943  {ISD::ADD, MVT::v8i8, 1},
944  {ISD::ADD, MVT::v16i8, 1},
945  {ISD::ADD, MVT::v4i16, 1},
946  {ISD::ADD, MVT::v8i16, 1},
947  {ISD::ADD, MVT::v4i32, 1},
948  };
949 
950  if (const auto *Entry = CostTableLookup(CostTblNoPairwise, ISD, MTy))
951  return LT.first * Entry->Cost;
952 
953  return BaseT::getArithmeticReductionCost(Opcode, ValTy, IsPairwiseForm);
954 }
955 
957  Type *SubTp) {
958  if (Kind == TTI::SK_Broadcast || Kind == TTI::SK_Transpose ||
959  Kind == TTI::SK_Select || Kind == TTI::SK_PermuteSingleSrc) {
960  static const CostTblEntry ShuffleTbl[] = {
961  // Broadcast shuffle kinds can be performed with 'dup'.
972  // Transpose shuffle kinds can be performed with 'trn1/trn2' and
973  // 'zip1/zip2' instructions.
984  // Select shuffle kinds.
985  // TODO: handle vXi8/vXi16.
986  { TTI::SK_Select, MVT::v2i32, 1 }, // mov.
987  { TTI::SK_Select, MVT::v4i32, 2 }, // rev+trn (or similar).
988  { TTI::SK_Select, MVT::v2i64, 1 }, // mov.
989  { TTI::SK_Select, MVT::v2f32, 1 }, // mov.
990  { TTI::SK_Select, MVT::v4f32, 2 }, // rev+trn (or similar).
991  { TTI::SK_Select, MVT::v2f64, 1 }, // mov.
992  // PermuteSingleSrc shuffle kinds.
993  // TODO: handle vXi8/vXi16.
994  { TTI::SK_PermuteSingleSrc, MVT::v2i32, 1 }, // mov.
995  { TTI::SK_PermuteSingleSrc, MVT::v4i32, 3 }, // perfectshuffle worst case.
996  { TTI::SK_PermuteSingleSrc, MVT::v2i64, 1 }, // mov.
997  { TTI::SK_PermuteSingleSrc, MVT::v2f32, 1 }, // mov.
998  { TTI::SK_PermuteSingleSrc, MVT::v4f32, 3 }, // perfectshuffle worst case.
999  { TTI::SK_PermuteSingleSrc, MVT::v2f64, 1 }, // mov.
1000  };
1001  std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, Tp);
1002  if (const auto *Entry = CostTableLookup(ShuffleTbl, Kind, LT.second))
1003  return LT.first * Entry->Cost;
1004  }
1005 
1006  return BaseT::getShuffleCost(Kind, Tp, Index, SubTp);
1007 }
Type * getVectorElementType() const
Definition: Type.h:376
static cl::opt< bool > EnableFalkorHWPFUnrollFix("enable-falkor-hwpf-unroll-fix", cl::init(true), cl::Hidden)
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool isConstantStridedAccessLessThan(ScalarEvolution *SE, const SCEV *Ptr, int64_t MergeDistance)
APInt sext(unsigned width) const
Sign extend to a new width.
Definition: APInt.cpp:913
bool isMisaligned128StoreSlow() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Type * getElementType(unsigned N) const
Definition: DerivedTypes.h:351
Cost tables and simple lookup functions.
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
unsigned getLoopDepth() const
Return the nesting level of this loop.
Definition: LoopInfo.h:97
unsigned getNumElements() const
Random access to the elements.
Definition: DerivedTypes.h:350
The main scalar evolution driver.
unsigned PartialOptSizeThreshold
The cost threshold for the unrolled loop when optimizing for size, like OptSizeThreshold, but used for partial/runtime unrolling (set to UINT_MAX to disable).
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:255
unsigned PartialThreshold
The cost threshold for the unrolled loop, like Threshold, but used for partial/runtime unrolling (set...
Type Conversion Cost Table.
Definition: CostTable.h:44
An instruction for reading from memory.
Definition: Instructions.h:169
static IntegerType * getInt64Ty(LLVMContext &C)
Definition: Type.cpp:181
bool isVectorTy() const
True if this is an instance of VectorType.
Definition: Type.h:230
unsigned getMaxInterleaveFactor(unsigned VF)
bool isOperationLegalOrCustom(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target or can be made legal with custom lower...
static void getFalkorUnrollingPreferences(Loop *L, ScalarEvolution &SE, TargetTransformInfo::UnrollingPreferences &UP)
Cost Table Entry.
Definition: CostTable.h:24
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1566
int getExtractWithExtendCost(unsigned Opcode, Type *Dst, VectorType *VecTy, unsigned Index)
int getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr)
Value * getArgOperand(unsigned i) const
Definition: InstrTypes.h:1246
const FeatureBitset & getFeatureBits() const
Class to represent struct types.
Definition: DerivedTypes.h:238
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:197
static bool isLogicalImmediate(uint64_t imm, unsigned regSize)
isLogicalImmediate - Return true if the immediate is valid for a logical immediate instruction of the...
unsigned getArithmeticReductionCost(unsigned Opcode, Type *Ty, bool IsPairwise)
Try to calculate arithmetic and shuffle op costs for reduction operations.
const TypeConversionCostTblEntry * ConvertCostTableLookup(ArrayRef< TypeConversionCostTblEntry > Tbl, int ISD, MVT Dst, MVT Src)
Find in type conversion cost table, TypeTy must be comparable to CompareTy by ==. ...
Definition: CostTable.h:54
bool isLegalInterleavedAccessType(VectorType *VecTy, const DataLayout &DL) const
Returns true if VecTy is a legal interleaved access type.
mir Rename Register Operands
int getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty)
unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I)
Definition: BasicTTIImpl.h:836
int64_t getSExtValue() const
Get sign extended value.
Definition: APInt.h:1632
unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
Definition: BasicTTIImpl.h:697
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:246
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
Definition: ISDOpcodes.h:539
This node represents a polynomial recurrence on the trip count of the specified loop.
PopcntSupportKind
Flags indicating the kind of support for population count.
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:202
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
Definition: APInt.cpp:963
int getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value *> Args=ArrayRef< const Value *>(), const Instruction *CxtI=nullptr)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
Selects elements from the corresponding lane of either source operand.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Definition: Instruction.h:125
unsigned getWideningBaseCost() const
int getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, const Instruction *I=nullptr)
Value * getOperand(unsigned i) const
Definition: User.h:169
Analysis containing CSE Info
Definition: CSEInfo.cpp:25
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info)
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
Definition: ISDOpcodes.h:585
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return &#39;this&#39;.
Definition: Type.h:307
int getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Definition: Instructions.h:892
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP)
Definition: BasicTTIImpl.h:441
bool useReductionIntrinsic(unsigned Opcode, Type *Ty, TTI::ReductionFlags Flags) const
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:435
Returns options for expansion of memcmp. IsZeroCmp is.
Value * getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, Type *ExpectedType)
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
bool requiresStrictAlign() const
Container class for subtarget features.
int getIntImmCost(int64_t Val)
Calculate the cost of materializing a 64-bit value.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition: MathExtras.h:465
Machine Value Type.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Definition: Type.cpp:115
Flags describing the kind of vector reduction.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
int getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index)
unsigned getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond=false, bool UseMaskForGaps=false)
Definition: BasicTTIImpl.h:915
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:158
bool shouldConsiderAddressTypePromotion(const Instruction &I, bool &AllowPromotionWithoutCommonHeader)
See if I should be considered for address type promotion.
Expected to fold away in lowering.
constexpr double e
Definition: MathExtras.h:57
bool isAffine() const
Return true if this represents an expression A + B*x where A and B are loop invariant values...
Value * getPointerOperand()
Definition: Instructions.h:295
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
int getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I=nullptr)
int getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, unsigned Alignment, unsigned AddressSpace, bool UseMaskForCond=false, bool UseMaskForGaps=false)
This file a TargetTransformInfo::Concept conforming object specific to the AArch64 target machine...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Definition: Function.cpp:223
Extended Value Type.
Definition: ValueTypes.h:34
static UndefValue * get(Type *T)
Static factory methods - Return an &#39;undef&#39; object of the specified type.
Definition: Constants.cpp:1514
size_t size() const
Definition: SmallVector.h:52
const TargetMachine & getTargetMachine() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
Definition: LoopInfo.cpp:62
OperandValueProperties
Additional properties of an operand&#39;s values.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Definition: IntrinsicInst.h:51
unsigned getShuffleCost(TTI::ShuffleKind Kind, Type *Tp, int Index, Type *SubTp)
Definition: BasicTTIImpl.h:678
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
Definition: APInt.h:963
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:390
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
Definition: Type.cpp:134
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
Definition: Alignment.h:117
int getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty)
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:837
int getCostOfKeepingLiveOverCall(ArrayRef< Type *> Tys)
AddressSpace
Definition: NVPTXBaseInfo.h:21
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info=TTI::OK_AnyValue, TTI::OperandValueKind Opd2Info=TTI::OK_AnyValue, TTI::OperandValueProperties Opd1PropInfo=TTI::OP_None, TTI::OperandValueProperties Opd2PropInfo=TTI::OP_None, ArrayRef< const Value * > Args=ArrayRef< const Value * >(), const Instruction *CxtI=nullptr)
Definition: BasicTTIImpl.h:630
void getUnrollingPreferences(Loop *L, ScalarEvolution &SE, TTI::UnrollingPreferences &UP)
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target&#39;s TargetSubtargetInf...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:585
unsigned getVectorNumElements() const
Definition: DerivedTypes.h:566
Class to represent vector types.
Definition: DerivedTypes.h:432
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Class for arbitrary precision integers.
Definition: APInt.h:69
unsigned getMaxInterleaveFactor() const
int getArithmeticReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm)
Select(COND, TRUEVAL, FALSEVAL).
Definition: ISDOpcodes.h:481
unsigned getMaxExpandSizeMemcmp(bool OptSize) const
Get maximum # of load operations permitted for memcmp.
iterator_range< user_iterator > users()
Definition: Value.h:420
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition: ISDOpcodes.h:529
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
void expandMOVImm(uint64_t Imm, unsigned BitSize, SmallVectorImpl< ImmInsnModel > &Insn)
Expand a MOVi32imm or MOVi64imm pseudo instruction to one or more real move-immediate instructions to...
const CostTblEntry * CostTableLookup(ArrayRef< CostTblEntry > Tbl, int ISD, MVT Ty)
Find in cost table, TypeTy must be comparable to CompareTy by ==.
Definition: CostTable.h:31
unsigned getNumArgOperands() const
Definition: InstrTypes.h:1244
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:448
This class represents an analyzed expression in the program.
unsigned getNumInterleavedAccesses(VectorType *VecTy, const DataLayout &DL) const
Returns the number of interleaved accesses that will be generated when lowering accesses of the given...
Represents a single loop in the control flow graph.
Definition: LoopInfo.h:509
static bool hasOneUse(unsigned Reg, MachineInstr *Def, MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS)
Parameters that control the generic loop unrolling transformation.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:614
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:106
#define I(x, y, z)
Definition: MD5.cpp:58
ARMProcFamilyEnum getProcFamily() const
Returns ARM processor family.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:332
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
Definition: Value.h:396
The cost of a typical &#39;add&#39; instruction.
LLVM Value Representation.
Definition: Value.h:74
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:279
Broadcast element 0 to all other elements.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
Type * getElementType() const
Definition: DerivedTypes.h:399
Value * PtrVal
This is the pointer that the intrinsic is loading from or storing to.
int getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I=nullptr)
bool hasOneUse() const
Return true if there is exactly one user of this value.
Definition: Value.h:433
OperandValueKind
Additional information about an operand&#39;s possible values.
This pass exposes codegen information to IR-level passes.
Conversion operators.
Definition: ISDOpcodes.h:526
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Definition: IRBuilder.h:2570
TRUNCATE - Completely drop the high bits.
Definition: ISDOpcodes.h:535
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
Definition: ValueTypes.h:126
#define LLVM_DEBUG(X)
Definition: Debug.h:122
iterator_range< block_iterator > blocks() const
Definition: LoopInfo.h:161
Information about a load/store intrinsic defined by the target.
bool NoNaN
If op is an fp min/max, whether NaNs may be present.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
std::pair< int, MVT > getTypeLegalizationCost(const DataLayout &DL, Type *Ty) const
Estimate the cost of type-legalization and the legalized type.
A wrapper class for inspecting calls to intrinsic functions.
Definition: IntrinsicInst.h:44
This file describes how to lower LLVM code to machine code.
const BasicBlock * getParent() const
Definition: Instruction.h:66
unsigned getVectorInsertExtractBaseCost() const
ShuffleKind
The various kinds of shuffle patterns for vector queries.
Shuffle elements of single source vector with any shuffle mask.
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
Definition: ISDOpcodes.h:441