LLVM 22.0.0git
AMDGPULateCodeGenPrepare.cpp
Go to the documentation of this file.
1//===-- AMDGPUCodeGenPrepare.cpp ------------------------------------------===//
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/// \file
10/// This pass does misc. AMDGPU optimizations on IR *just* before instruction
11/// selection.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPU.h"
16#include "AMDGPUTargetMachine.h"
21#include "llvm/IR/IRBuilder.h"
22#include "llvm/IR/InstVisitor.h"
23#include "llvm/IR/IntrinsicsAMDGPU.h"
28
29#define DEBUG_TYPE "amdgpu-late-codegenprepare"
30
31using namespace llvm;
32
33// Scalar load widening needs running after load-store-vectorizer as that pass
34// doesn't handle overlapping cases. In addition, this pass enhances the
35// widening to handle cases where scalar sub-dword loads are naturally aligned
36// only but not dword aligned.
37static cl::opt<bool>
38 WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads",
39 cl::desc("Widen sub-dword constant address space loads in "
40 "AMDGPULateCodeGenPrepare"),
42
43namespace {
44
45class AMDGPULateCodeGenPrepare
46 : public InstVisitor<AMDGPULateCodeGenPrepare, bool> {
47 Function &F;
48 const DataLayout &DL;
49 const GCNSubtarget &ST;
50
51 AssumptionCache *const AC;
53
55
56public:
57 AMDGPULateCodeGenPrepare(Function &F, const GCNSubtarget &ST,
59 : F(F), DL(F.getDataLayout()), ST(ST), AC(AC), UA(UA) {}
60 bool run();
61 bool visitInstruction(Instruction &) { return false; }
62
63 // Check if the specified value is at least DWORD aligned.
64 bool isDWORDAligned(const Value *V) const {
65 KnownBits Known = computeKnownBits(V, DL, AC);
66 return Known.countMinTrailingZeros() >= 2;
67 }
68
69 bool canWidenScalarExtLoad(LoadInst &LI) const;
70 bool visitLoadInst(LoadInst &LI);
71};
72
74
75class LiveRegOptimizer {
76private:
77 Module &Mod;
78 const DataLayout &DL;
79 const GCNSubtarget &ST;
80
81 /// The scalar type to convert to
82 Type *const ConvertToScalar;
83 /// Map of Value -> Converted Value
84 ValueToValueMap ValMap;
85 /// Map of containing conversions from Optimal Type -> Original Type per BB.
87
88public:
89 /// Calculate the and \p return the type to convert to given a problematic \p
90 /// OriginalType. In some instances, we may widen the type (e.g. v2i8 -> i32).
91 Type *calculateConvertType(Type *OriginalType);
92 /// Convert the virtual register defined by \p V to the compatible vector of
93 /// legal type
94 Value *convertToOptType(Instruction *V, BasicBlock::iterator &InstPt);
95 /// Convert the virtual register defined by \p V back to the original type \p
96 /// ConvertType, stripping away the MSBs in cases where there was an imperfect
97 /// fit (e.g. v2i32 -> v7i8)
98 Value *convertFromOptType(Type *ConvertType, Instruction *V,
100 BasicBlock *InsertBlock);
101 /// Check for problematic PHI nodes or cross-bb values based on the value
102 /// defined by \p I, and coerce to legal types if necessary. For problematic
103 /// PHI node, we coerce all incoming values in a single invocation.
104 bool optimizeLiveType(Instruction *I,
106
107 // Whether or not the type should be replaced to avoid inefficient
108 // legalization code
109 bool shouldReplace(Type *ITy) {
110 FixedVectorType *VTy = dyn_cast<FixedVectorType>(ITy);
111 if (!VTy)
112 return false;
113
114 const auto *TLI = ST.getTargetLowering();
115
116 Type *EltTy = VTy->getElementType();
117 // If the element size is not less than the convert to scalar size, then we
118 // can't do any bit packing
119 if (!EltTy->isIntegerTy() ||
120 EltTy->getScalarSizeInBits() > ConvertToScalar->getScalarSizeInBits())
121 return false;
122
123 // Only coerce illegal types
125 TLI->getTypeConversion(EltTy->getContext(), EVT::getEVT(EltTy, false));
126 return LK.first != TargetLoweringBase::TypeLegal;
127 }
128
129 bool isOpLegal(Instruction *I) { return isa<StoreInst, IntrinsicInst>(I); }
130
131 bool isCoercionProfitable(Instruction *II) {
134
135 // Check users for profitable conditions (across block user which can
136 // natively handle the illegal vector).
137 for (User *V : II->users())
138 if (auto *UseInst = dyn_cast<Instruction>(V))
139 UserList.push_back(UseInst);
140
141 auto IsLookThru = [](Instruction *II) {
142 if (const auto *Intr = dyn_cast<IntrinsicInst>(II))
143 return Intr->getIntrinsicID() == Intrinsic::amdgcn_perm;
146 };
147
148 while (!UserList.empty()) {
149 auto CII = UserList.pop_back_val();
150 if (!CVisited.insert(CII).second)
151 continue;
152
153 if (CII->getParent() == II->getParent() && !IsLookThru(II))
154 continue;
155
156 if (isOpLegal(CII))
157 return true;
158
159 if (IsLookThru(CII))
160 for (User *V : CII->users())
161 if (auto *UseInst = dyn_cast<Instruction>(V))
162 UserList.push_back(UseInst);
163 }
164 return false;
165 }
166
167 LiveRegOptimizer(Module &Mod, const GCNSubtarget &ST)
168 : Mod(Mod), DL(Mod.getDataLayout()), ST(ST),
169 ConvertToScalar(Type::getInt32Ty(Mod.getContext())) {}
170};
171
172} // end anonymous namespace
173
174bool AMDGPULateCodeGenPrepare::run() {
175 // "Optimize" the virtual regs that cross basic block boundaries. When
176 // building the SelectionDAG, vectors of illegal types that cross basic blocks
177 // will be scalarized and widened, with each scalar living in its
178 // own register. To work around this, this optimization converts the
179 // vectors to equivalent vectors of legal type (which are converted back
180 // before uses in subsequent blocks), to pack the bits into fewer physical
181 // registers (used in CopyToReg/CopyFromReg pairs).
182 LiveRegOptimizer LRO(*F.getParent(), ST);
183
184 bool Changed = false;
185
186 bool HasScalarSubwordLoads = ST.hasScalarSubwordLoads();
187
188 for (auto &BB : reverse(F))
190 Changed |= !HasScalarSubwordLoads && visit(I);
191 Changed |= LRO.optimizeLiveType(&I, DeadInsts);
192 }
193
195 return Changed;
196}
197
198Type *LiveRegOptimizer::calculateConvertType(Type *OriginalType) {
199 assert(OriginalType->getScalarSizeInBits() <=
200 ConvertToScalar->getScalarSizeInBits());
201
202 FixedVectorType *VTy = cast<FixedVectorType>(OriginalType);
203
204 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
205 TypeSize ConvertScalarSize = DL.getTypeSizeInBits(ConvertToScalar);
206 unsigned ConvertEltCount =
207 (OriginalSize + ConvertScalarSize - 1) / ConvertScalarSize;
208
209 if (OriginalSize <= ConvertScalarSize)
210 return IntegerType::get(Mod.getContext(), ConvertScalarSize);
211
212 return VectorType::get(Type::getIntNTy(Mod.getContext(), ConvertScalarSize),
213 ConvertEltCount, false);
214}
215
216Value *LiveRegOptimizer::convertToOptType(Instruction *V,
217 BasicBlock::iterator &InsertPt) {
218 FixedVectorType *VTy = cast<FixedVectorType>(V->getType());
219 Type *NewTy = calculateConvertType(V->getType());
220
221 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
222 TypeSize NewSize = DL.getTypeSizeInBits(NewTy);
223
224 IRBuilder<> Builder(V->getParent(), InsertPt);
225 // If there is a bitsize match, we can fit the old vector into a new vector of
226 // desired type.
227 if (OriginalSize == NewSize)
228 return Builder.CreateBitCast(V, NewTy, V->getName() + ".bc");
229
230 // If there is a bitsize mismatch, we must use a wider vector.
231 assert(NewSize > OriginalSize);
232 uint64_t ExpandedVecElementCount = NewSize / VTy->getScalarSizeInBits();
233
234 SmallVector<int, 8> ShuffleMask;
235 uint64_t OriginalElementCount = VTy->getElementCount().getFixedValue();
236 for (unsigned I = 0; I < OriginalElementCount; I++)
237 ShuffleMask.push_back(I);
238
239 for (uint64_t I = OriginalElementCount; I < ExpandedVecElementCount; I++)
240 ShuffleMask.push_back(OriginalElementCount);
241
242 Value *ExpandedVec = Builder.CreateShuffleVector(V, ShuffleMask);
243 return Builder.CreateBitCast(ExpandedVec, NewTy, V->getName() + ".bc");
244}
245
246Value *LiveRegOptimizer::convertFromOptType(Type *ConvertType, Instruction *V,
247 BasicBlock::iterator &InsertPt,
248 BasicBlock *InsertBB) {
249 FixedVectorType *NewVTy = cast<FixedVectorType>(ConvertType);
250
251 TypeSize OriginalSize = DL.getTypeSizeInBits(V->getType());
252 TypeSize NewSize = DL.getTypeSizeInBits(NewVTy);
253
254 IRBuilder<> Builder(InsertBB, InsertPt);
255 // If there is a bitsize match, we simply convert back to the original type.
256 if (OriginalSize == NewSize)
257 return Builder.CreateBitCast(V, NewVTy, V->getName() + ".bc");
258
259 // If there is a bitsize mismatch, then we must have used a wider value to
260 // hold the bits.
261 assert(OriginalSize > NewSize);
262 // For wide scalars, we can just truncate the value.
263 if (!V->getType()->isVectorTy()) {
264 Instruction *Trunc = cast<Instruction>(
265 Builder.CreateTrunc(V, IntegerType::get(Mod.getContext(), NewSize)));
266 return cast<Instruction>(Builder.CreateBitCast(Trunc, NewVTy));
267 }
268
269 // For wider vectors, we must strip the MSBs to convert back to the original
270 // type.
271 VectorType *ExpandedVT = VectorType::get(
272 Type::getIntNTy(Mod.getContext(), NewVTy->getScalarSizeInBits()),
273 (OriginalSize / NewVTy->getScalarSizeInBits()), false);
274 Instruction *Converted =
275 cast<Instruction>(Builder.CreateBitCast(V, ExpandedVT));
276
277 unsigned NarrowElementCount = NewVTy->getElementCount().getFixedValue();
278 SmallVector<int, 8> ShuffleMask(NarrowElementCount);
279 std::iota(ShuffleMask.begin(), ShuffleMask.end(), 0);
280
281 return Builder.CreateShuffleVector(Converted, ShuffleMask);
282}
283
284bool LiveRegOptimizer::optimizeLiveType(
291
292 Worklist.push_back(cast<Instruction>(I));
293 while (!Worklist.empty()) {
294 Instruction *II = Worklist.pop_back_val();
295
296 if (!Visited.insert(II).second)
297 continue;
298
299 if (!shouldReplace(II->getType()))
300 continue;
301
302 if (!isCoercionProfitable(II))
303 continue;
304
305 if (PHINode *Phi = dyn_cast<PHINode>(II)) {
306 PhiNodes.insert(Phi);
307 // Collect all the incoming values of problematic PHI nodes.
308 for (Value *V : Phi->incoming_values()) {
309 // Repeat the collection process for newly found PHI nodes.
310 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
311 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
312 Worklist.push_back(OpPhi);
313 continue;
314 }
315
316 Instruction *IncInst = dyn_cast<Instruction>(V);
317 // Other incoming value types (e.g. vector literals) are unhandled
318 if (!IncInst && !isa<ConstantAggregateZero>(V))
319 return false;
320
321 // Collect all other incoming values for coercion.
322 if (IncInst)
323 Defs.insert(IncInst);
324 }
325 }
326
327 // Collect all relevant uses.
328 for (User *V : II->users()) {
329 // Repeat the collection process for problematic PHI nodes.
330 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
331 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
332 Worklist.push_back(OpPhi);
333 continue;
334 }
335
336 Instruction *UseInst = cast<Instruction>(V);
337 // Collect all uses of PHINodes and any use the crosses BB boundaries.
338 if (UseInst->getParent() != II->getParent() || isa<PHINode>(II)) {
339 Uses.insert(UseInst);
340 if (!isa<PHINode>(II))
341 Defs.insert(II);
342 }
343 }
344 }
345
346 // Coerce and track the defs.
347 for (Instruction *D : Defs) {
348 if (!ValMap.contains(D)) {
349 BasicBlock::iterator InsertPt = std::next(D->getIterator());
350 Value *ConvertVal = convertToOptType(D, InsertPt);
351 assert(ConvertVal);
352 ValMap[D] = ConvertVal;
353 }
354 }
355
356 // Construct new-typed PHI nodes.
357 for (PHINode *Phi : PhiNodes) {
358 ValMap[Phi] = PHINode::Create(calculateConvertType(Phi->getType()),
359 Phi->getNumIncomingValues(),
360 Phi->getName() + ".tc", Phi->getIterator());
361 }
362
363 // Connect all the PHI nodes with their new incoming values.
364 for (PHINode *Phi : PhiNodes) {
365 PHINode *NewPhi = cast<PHINode>(ValMap[Phi]);
366 bool MissingIncVal = false;
367 for (int I = 0, E = Phi->getNumIncomingValues(); I < E; I++) {
368 Value *IncVal = Phi->getIncomingValue(I);
369 if (isa<ConstantAggregateZero>(IncVal)) {
370 Type *NewType = calculateConvertType(Phi->getType());
371 NewPhi->addIncoming(ConstantInt::get(NewType, 0, false),
372 Phi->getIncomingBlock(I));
373 } else if (Value *Val = ValMap.lookup(IncVal))
374 NewPhi->addIncoming(Val, Phi->getIncomingBlock(I));
375 else
376 MissingIncVal = true;
377 }
378 if (MissingIncVal) {
379 Value *DeadVal = ValMap[Phi];
380 // The coercion chain of the PHI is broken. Delete the Phi
381 // from the ValMap and any connected / user Phis.
382 SmallVector<Value *, 4> PHIWorklist;
383 SmallPtrSet<Value *, 4> VisitedPhis;
384 PHIWorklist.push_back(DeadVal);
385 while (!PHIWorklist.empty()) {
386 Value *NextDeadValue = PHIWorklist.pop_back_val();
387 VisitedPhis.insert(NextDeadValue);
388 auto OriginalPhi =
389 llvm::find_if(PhiNodes, [this, &NextDeadValue](PHINode *CandPhi) {
390 return ValMap[CandPhi] == NextDeadValue;
391 });
392 // This PHI may have already been removed from maps when
393 // unwinding a previous Phi
394 if (OriginalPhi != PhiNodes.end())
395 ValMap.erase(*OriginalPhi);
396
397 DeadInsts.emplace_back(cast<Instruction>(NextDeadValue));
398
399 for (User *U : NextDeadValue->users()) {
400 if (!VisitedPhis.contains(cast<PHINode>(U)))
401 PHIWorklist.push_back(U);
402 }
403 }
404 } else {
405 DeadInsts.emplace_back(cast<Instruction>(Phi));
406 }
407 }
408 // Coerce back to the original type and replace the uses.
409 for (Instruction *U : Uses) {
410 // Replace all converted operands for a use.
411 for (auto [OpIdx, Op] : enumerate(U->operands())) {
412 if (Value *Val = ValMap.lookup(Op)) {
413 Value *NewVal = nullptr;
414 if (BBUseValMap.contains(U->getParent()) &&
415 BBUseValMap[U->getParent()].contains(Val))
416 NewVal = BBUseValMap[U->getParent()][Val];
417 else {
418 BasicBlock::iterator InsertPt = U->getParent()->getFirstNonPHIIt();
419 // We may pick up ops that were previously converted for users in
420 // other blocks. If there is an originally typed definition of the Op
421 // already in this block, simply reuse it.
422 if (isa<Instruction>(Op) && !isa<PHINode>(Op) &&
423 U->getParent() == cast<Instruction>(Op)->getParent()) {
424 NewVal = Op;
425 } else {
426 NewVal =
427 convertFromOptType(Op->getType(), cast<Instruction>(ValMap[Op]),
428 InsertPt, U->getParent());
429 BBUseValMap[U->getParent()][ValMap[Op]] = NewVal;
430 }
431 }
432 assert(NewVal);
433 U->setOperand(OpIdx, NewVal);
434 }
435 }
436 }
437
438 return true;
439}
440
441bool AMDGPULateCodeGenPrepare::canWidenScalarExtLoad(LoadInst &LI) const {
442 unsigned AS = LI.getPointerAddressSpace();
443 // Skip non-constant address space.
444 if (AS != AMDGPUAS::CONSTANT_ADDRESS &&
446 return false;
447 // Skip non-simple loads.
448 if (!LI.isSimple())
449 return false;
450 Type *Ty = LI.getType();
451 // Skip aggregate types.
452 if (Ty->isAggregateType())
453 return false;
454 unsigned TySize = DL.getTypeStoreSize(Ty);
455 // Only handle sub-DWORD loads.
456 if (TySize >= 4)
457 return false;
458 // That load must be at least naturally aligned.
459 if (LI.getAlign() < DL.getABITypeAlign(Ty))
460 return false;
461 // It should be uniform, i.e. a scalar load.
462 return UA.isUniform(&LI);
463}
464
465bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) {
466 if (!WidenLoads)
467 return false;
468
469 // Skip if that load is already aligned on DWORD at least as it's handled in
470 // SDAG.
471 if (LI.getAlign() >= 4)
472 return false;
473
474 if (!canWidenScalarExtLoad(LI))
475 return false;
476
477 int64_t Offset = 0;
478 auto *Base =
480 // If that base is not DWORD aligned, it's not safe to perform the following
481 // transforms.
482 if (!isDWORDAligned(Base))
483 return false;
484
485 int64_t Adjust = Offset & 0x3;
486 if (Adjust == 0) {
487 // With a zero adjust, the original alignment could be promoted with a
488 // better one.
489 LI.setAlignment(Align(4));
490 return true;
491 }
492
493 IRBuilder<> IRB(&LI);
494 IRB.SetCurrentDebugLocation(LI.getDebugLoc());
495
496 unsigned LdBits = DL.getTypeStoreSizeInBits(LI.getType());
497 auto *IntNTy = Type::getIntNTy(LI.getContext(), LdBits);
498
499 auto *NewPtr = IRB.CreateConstGEP1_64(
500 IRB.getInt8Ty(),
501 IRB.CreateAddrSpaceCast(Base, LI.getPointerOperand()->getType()),
502 Offset - Adjust);
503
504 LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4));
505 NewLd->copyMetadata(LI);
506 NewLd->setMetadata(LLVMContext::MD_range, nullptr);
507
508 unsigned ShAmt = Adjust * 8;
509 Value *NewVal = IRB.CreateBitCast(
510 IRB.CreateTrunc(IRB.CreateLShr(NewLd, ShAmt),
511 DL.typeSizeEqualsStoreSize(LI.getType()) ? IntNTy
512 : LI.getType()),
513 LI.getType());
514 LI.replaceAllUsesWith(NewVal);
515 DeadInsts.emplace_back(&LI);
516
517 return true;
518}
519
522 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
525
526 bool Changed = AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
527
528 if (!Changed)
529 return PreservedAnalyses::all();
532 return PA;
533}
534
536public:
537 static char ID;
538
540
541 StringRef getPassName() const override {
542 return "AMDGPU IR late optimizations";
543 }
544
545 void getAnalysisUsage(AnalysisUsage &AU) const override {
549 // Invalidates UniformityInfo
550 AU.setPreservesCFG();
551 }
552
553 bool runOnFunction(Function &F) override;
554};
555
557 if (skipFunction(F))
558 return false;
559
560 const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
561 const TargetMachine &TM = TPC.getTM<TargetMachine>();
562 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
563
564 AssumptionCache &AC =
565 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
566 UniformityInfo &UI =
567 getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo();
568
569 return AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
570}
571
573 "AMDGPU IR late optimizations", false, false)
579
581
584}
aarch64 falkor hwpf fix late
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Intr
static cl::opt< bool > WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads", cl::desc("Widen sub-dword constant address space loads in " "AMDGPULateCodeGenPrepare"), cl::ReallyHidden, cl::init(true))
The AMDGPU TargetMachine interface definition for hw codegen targets.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static bool runOnFunction(Function &F, bool PostInlining)
#define DEBUG_TYPE
Legalize the Machine IR a function s Machine IR
Definition: Legalizer.cpp:80
Generic memory optimizations
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
if(auto Err=PB.parsePassPipeline(MPM, Passes)) return wrap(std MPM run * Mod
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:42
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:39
Remove Loads Into Fake Uses
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> op)
Target-Independent Code Generator Pass Configuration Options pass.
LLVM IR instance of the generic uniformity analysis.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
PreservedAnalyses run(Function &, FunctionAnalysisManager &)
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:412
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition: Pass.cpp:270
A function analysis which provides an AssumptionCache.
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
Definition: BasicBlock.h:62
InstListType::iterator iterator
Instruction iterators...
Definition: BasicBlock.h:170
Represents analyses that only rely on functions' control flow.
Definition: Analysis.h:73
This is the base class for all instructions that perform data casts.
Definition: InstrTypes.h:448
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:203
bool erase(const KeyT &Val)
Definition: DenseMap.h:319
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition: DenseMap.h:168
This instruction extracts a single (scalar) element from a VectorType value.
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:592
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:314
bool isUniform(ConstValueRefT V) const
Whether V is uniform/non-divergent.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:2780
This instruction inserts a single (scalar) element into a VectorType value.
Base class for instruction visitors.
Definition: InstVisitor.h:78
void visitInstruction(Instruction &I)
Definition: InstVisitor.h:275
RetTy visitLoadInst(LoadInst &I)
Definition: InstVisitor.h:169
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Definition: Instruction.h:513
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1718
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:319
An instruction for reading from memory.
Definition: Instructions.h:180
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Definition: Instructions.h:265
void setAlignment(Align Align)
Definition: Instructions.h:219
Value * getPointerOperand()
Definition: Instructions.h:259
bool isSimple() const
Definition: Instructions.h:251
Align getAlign() const
Return the alignment of the access that is being performed.
Definition: Instructions.h:215
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition: Analysis.h:151
This instruction constructs a fixed permutation of two input vectors.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:470
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:401
bool contains(ConstPtrType Ptr) const
Definition: SmallPtrSet.h:476
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:541
bool empty() const
Definition: SmallVector.h:82
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:938
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
std::pair< LegalizeTypeAction, EVT > LegalizeKind
LegalizeKind holds the legalization kind that needs to happen to EVT in order to type-legalize it.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
Target-Independent Code Generator Pass Configuration Options.
TMC & getTM() const
Get the right type of TargetMachine for this target.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition: Type.h:304
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:240
Analysis pass which computes UniformityInfo.
Legacy analysis pass which computes a CycleInfo.
LLVM Value Representation.
Definition: Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:546
iterator_range< user_iterator > users()
Definition: Value.h:426
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:1098
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Definition: DerivedTypes.h:695
Type * getElementType() const
Definition: DerivedTypes.h:463
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:203
const ParentTy * getParent() const
Definition: ilist_node.h:34
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
@ ReallyHidden
Definition: CommandLine.h:139
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:444
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
NodeAddr< PhiNode * > Phi
Definition: RDFGraph.h:390
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
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:2491
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition: STLExtras.h:663
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:428
LLVM_ABI void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true, unsigned Depth=0)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
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:548
DWARFExpression::Operation Op
LLVM_ABI bool RecursivelyDeleteTriviallyDeadInstructionsPermissive(SmallVectorImpl< WeakTrackingVH > &DeadInsts, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
Same functionality as RecursivelyDeleteTriviallyDeadInstructions, but allow instructions that are not...
Definition: Local.cpp:548
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1777
FunctionPass * createAMDGPULateCodeGenPrepareLegacyPass()
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
Definition: ValueTypes.cpp:299
unsigned countMinTrailingZeros() const
Returns the minimum number of trailing zero bits.
Definition: KnownBits.h:235