LLVM 24.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 "AMDGPUMemoryUtils.h"
17#include "AMDGPUTargetMachine.h"
19#include "llvm/Analysis/Loads.h"
23#include "llvm/IR/IRBuilder.h"
24#include "llvm/IR/InstVisitor.h"
25#include "llvm/IR/IntrinsicsAMDGPU.h"
29
30#define DEBUG_TYPE "amdgpu-late-codegenprepare"
31
32using namespace llvm;
33
34// Scalar load widening needs running after load-store-vectorizer as that pass
35// doesn't handle overlapping cases. In addition, this pass enhances the
36// widening to handle cases where scalar sub-dword loads are naturally aligned
37// only but not dword aligned.
38static cl::opt<bool>
39 WidenLoads("amdgpu-late-codegenprepare-widen-constant-loads",
40 cl::desc("Widen sub-dword constant address space loads in "
41 "AMDGPULateCodeGenPrepare"),
43
44namespace {
45
46class AMDGPULateCodeGenPrepare
47 : public InstVisitor<AMDGPULateCodeGenPrepare, bool> {
48 Function &F;
49 const DataLayout &DL;
50 const GCNSubtarget &ST;
51
52 AssumptionCache *const AC;
54
56
57public:
58 AMDGPULateCodeGenPrepare(Function &F, const GCNSubtarget &ST,
60 : F(F), DL(F.getDataLayout()), ST(ST), AC(AC), UA(UA) {}
61 bool run();
62 bool visitInstruction(Instruction &) { return false; }
63
64 // Widening may read padding bytes past the original access, so require the
65 // whole AccessSize-byte range at Base to be dereferenceable, not just Base
66 // itself aligned.
67 bool isSafeToWidenLoad(const Value *Base, uint64_t AccessSize,
68 const Instruction *CxtI) const {
70 Base, Align(4),
71 APInt(DL.getIndexTypeSizeInBits(Base->getType()), AccessSize),
72 SimplifyQuery(DL, /*TLI=*/nullptr, /*DT=*/nullptr, AC, CxtI));
73 }
74
75 bool canWidenScalarExtLoad(LoadInst &LI) const;
76 bool visitLoadInst(LoadInst &LI);
77};
78
80
81class LiveRegOptimizer {
82private:
83 Module &Mod;
84 const DataLayout &DL;
85 const GCNSubtarget &ST;
86
87 /// The scalar type to convert to
88 Type *const ConvertToScalar;
89 /// Map of Value -> Converted Value
90 ValueToValueMap ValMap;
91 /// Map of containing conversions from Optimal Type -> Original Type per BB.
92 DenseMap<BasicBlock *, ValueToValueMap> BBUseValMap;
93
94public:
95 /// Calculate the and \p return the type to convert to given a problematic \p
96 /// OriginalType. In some instances, we may widen the type (e.g. v2i8 -> i32).
97 Type *calculateConvertType(Type *OriginalType);
98 /// Convert the virtual register defined by \p V to the compatible vector of
99 /// legal type
100 Value *convertToOptType(Instruction *V, BasicBlock::iterator &InstPt);
101 /// Convert the virtual register defined by \p V back to the original type \p
102 /// ConvertType, stripping away the MSBs in cases where there was an imperfect
103 /// fit (e.g. v2i32 -> v7i8)
104 Value *convertFromOptType(Type *ConvertType, Instruction *V,
105 BasicBlock::iterator &InstPt,
106 BasicBlock *InsertBlock);
107 /// Check for problematic PHI nodes or cross-bb values based on the value
108 /// defined by \p I, and coerce to legal types if necessary. For problematic
109 /// PHI node, we coerce all incoming values in a single invocation.
110 bool optimizeLiveType(Instruction *I,
111 SmallVectorImpl<WeakTrackingVH> &DeadInsts);
112
113 // Whether or not the type should be replaced to avoid inefficient
114 // legalization code
115 bool shouldReplace(Type *ITy) {
116 FixedVectorType *VTy = dyn_cast<FixedVectorType>(ITy);
117 if (!VTy)
118 return false;
119
120 const auto *TLI = ST.getTargetLowering();
121
122 Type *EltTy = VTy->getElementType();
123 // If the element size is not is not a multiple scalar size, then we can't
124 // do any bit packing
125 if (!EltTy->isIntegerTy() ||
126 ConvertToScalar->getScalarSizeInBits() % EltTy->getScalarSizeInBits())
127 return false;
128
129 // Only coerce illegal types
131 TLI->getTypeConversion(EltTy->getContext(), EVT::getEVT(EltTy, false));
132 return LK.first != TargetLoweringBase::TypeLegal;
133 }
134
135 bool isOpLegal(const Instruction *I) {
137 return true;
138
139 // Any store is a profitable sink (prevents flip-flopping)
140 if (isa<StoreInst>(I))
141 return true;
142
143 if (auto *BO = dyn_cast<BinaryOperator>(I)) {
144 if (auto *VT = dyn_cast<FixedVectorType>(BO->getType())) {
145 if (const auto *IT = dyn_cast<IntegerType>(VT->getElementType())) {
146 unsigned EB = IT->getBitWidth();
147 unsigned EC = VT->getNumElements();
148 // Check for SDWA-compatible operation
149 if ((EB == 8 || EB == 16) && ST.hasSDWA() && EC * EB <= 32) {
150 switch (BO->getOpcode()) {
151 case Instruction::Add:
152 case Instruction::Sub:
153 case Instruction::And:
154 case Instruction::Or:
155 case Instruction::Xor:
156 return true;
157 default:
158 break;
159 }
160 }
161 }
162 }
163 }
164
165 return false;
166 }
167
168 bool isCoercionProfitable(Instruction *II) {
169 SmallPtrSet<Instruction *, 4> CVisited;
170 SmallVector<Instruction *, 4> UserList;
171
172 // Check users for profitable conditions (across block user which can
173 // natively handle the illegal vector).
174 for (User *V : II->users())
175 if (auto *UseInst = dyn_cast<Instruction>(V))
176 UserList.push_back(UseInst);
177
178 auto IsLookThru = [](Instruction *II) {
179 if (const auto *Intr = dyn_cast<IntrinsicInst>(II))
180 return Intr->getIntrinsicID() == Intrinsic::amdgcn_perm;
181 return isa<PHINode, ShuffleVectorInst, InsertElementInst,
182 ExtractElementInst, CastInst>(II);
183 };
184
185 while (!UserList.empty()) {
186 auto CII = UserList.pop_back_val();
187 if (!CVisited.insert(CII).second)
188 continue;
189
190 // Same-BB filter must look at the *user*; and allow non-lookthrough
191 // users when the def is a PHI (loop-header pattern).
192 if (CII->getParent() == II->getParent() && !IsLookThru(CII) &&
194 continue;
195
196 if (isOpLegal(CII))
197 return true;
198
199 if (IsLookThru(CII))
200 for (User *V : CII->users())
201 if (auto *UseInst = dyn_cast<Instruction>(V))
202 UserList.push_back(UseInst);
203 }
204 return false;
205 }
206
207 LiveRegOptimizer(Module &Mod, const GCNSubtarget &ST)
208 : Mod(Mod), DL(Mod.getDataLayout()), ST(ST),
209 ConvertToScalar(Type::getInt32Ty(Mod.getContext())) {}
210};
211
212} // end anonymous namespace
213
214bool AMDGPULateCodeGenPrepare::run() {
215 // "Optimize" the virtual regs that cross basic block boundaries. When
216 // building the SelectionDAG, vectors of illegal types that cross basic blocks
217 // will be scalarized and widened, with each scalar living in its
218 // own register. To work around this, this optimization converts the
219 // vectors to equivalent vectors of legal type (which are converted back
220 // before uses in subsequent blocks), to pack the bits into fewer physical
221 // registers (used in CopyToReg/CopyFromReg pairs).
222 LiveRegOptimizer LRO(*F.getParent(), ST);
223
224 bool Changed = false;
225
226 bool HasScalarSubwordLoads = ST.hasScalarSubwordLoads();
227
228 for (auto &BB : reverse(F))
229 for (Instruction &I : make_early_inc_range(reverse(BB))) {
230 Changed |= !HasScalarSubwordLoads && visit(I);
231 Changed |= LRO.optimizeLiveType(&I, DeadInsts);
232 }
233
235 return Changed;
236}
237
238Type *LiveRegOptimizer::calculateConvertType(Type *OriginalType) {
239 assert(OriginalType->getScalarSizeInBits() <=
240 ConvertToScalar->getScalarSizeInBits());
241
242 FixedVectorType *VTy = cast<FixedVectorType>(OriginalType);
243
244 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
245 TypeSize ConvertScalarSize = DL.getTypeSizeInBits(ConvertToScalar);
246 unsigned ConvertEltCount =
247 (OriginalSize + ConvertScalarSize - 1) / ConvertScalarSize;
248
249 if (OriginalSize <= ConvertScalarSize)
250 return IntegerType::get(Mod.getContext(), ConvertScalarSize);
251
252 return VectorType::get(Type::getIntNTy(Mod.getContext(), ConvertScalarSize),
253 ConvertEltCount, false);
254}
255
256Value *LiveRegOptimizer::convertToOptType(Instruction *V,
257 BasicBlock::iterator &InsertPt) {
258 FixedVectorType *VTy = cast<FixedVectorType>(V->getType());
259 Type *NewTy = calculateConvertType(V->getType());
260
261 TypeSize OriginalSize = DL.getTypeSizeInBits(VTy);
262 TypeSize NewSize = DL.getTypeSizeInBits(NewTy);
263
264 IRBuilder<> Builder(V->getParent(), InsertPt);
265 // If there is a bitsize match, we can fit the old vector into a new vector of
266 // desired type.
267 if (OriginalSize == NewSize)
268 return Builder.CreateBitCast(V, NewTy, V->getName() + ".bc");
269
270 // If there is a bitsize mismatch, we must use a wider vector.
271 assert(NewSize > OriginalSize);
272 uint64_t ExpandedVecElementCount = NewSize / VTy->getScalarSizeInBits();
273
274 SmallVector<int, 8> ShuffleMask;
275 uint64_t OriginalElementCount = VTy->getElementCount().getFixedValue();
276 for (unsigned I = 0; I < OriginalElementCount; I++)
277 ShuffleMask.push_back(I);
278
279 for (uint64_t I = OriginalElementCount; I < ExpandedVecElementCount; I++)
280 ShuffleMask.push_back(OriginalElementCount);
281
282 Value *ExpandedVec = Builder.CreateShuffleVector(V, ShuffleMask);
283 return Builder.CreateBitCast(ExpandedVec, NewTy, V->getName() + ".bc");
284}
285
286Value *LiveRegOptimizer::convertFromOptType(Type *ConvertType, Instruction *V,
287 BasicBlock::iterator &InsertPt,
288 BasicBlock *InsertBB) {
289 FixedVectorType *NewVTy = cast<FixedVectorType>(ConvertType);
290
291 TypeSize OriginalSize = DL.getTypeSizeInBits(V->getType());
292 TypeSize NewSize = DL.getTypeSizeInBits(NewVTy);
293
294 IRBuilder<> Builder(InsertBB, InsertPt);
295 // If there is a bitsize match, we simply convert back to the original type.
296 if (OriginalSize == NewSize)
297 return Builder.CreateBitCast(V, NewVTy, V->getName() + ".bc");
298
299 // If there is a bitsize mismatch, then we must have used a wider value to
300 // hold the bits.
301 assert(OriginalSize > NewSize);
302 // For wide scalars, we can just truncate the value.
303 if (!V->getType()->isVectorTy()) {
305 Builder.CreateTrunc(V, IntegerType::get(Mod.getContext(), NewSize)));
306 return cast<Instruction>(Builder.CreateBitCast(Trunc, NewVTy));
307 }
308
309 // For wider vectors, we must strip the MSBs to convert back to the original
310 // type.
311 VectorType *ExpandedVT = VectorType::get(
312 Type::getIntNTy(Mod.getContext(), NewVTy->getScalarSizeInBits()),
313 (OriginalSize / NewVTy->getScalarSizeInBits()), false);
314 Instruction *Converted =
315 cast<Instruction>(Builder.CreateBitCast(V, ExpandedVT));
316
317 unsigned NarrowElementCount = NewVTy->getElementCount().getFixedValue();
318 SmallVector<int, 8> ShuffleMask(NarrowElementCount);
319 std::iota(ShuffleMask.begin(), ShuffleMask.end(), 0);
320
321 return Builder.CreateShuffleVector(Converted, ShuffleMask);
322}
323
324bool LiveRegOptimizer::optimizeLiveType(
325 Instruction *I, SmallVectorImpl<WeakTrackingVH> &DeadInsts) {
326 SmallVector<Instruction *, 4> Worklist;
327 SmallPtrSet<PHINode *, 4> PhiNodes;
328 SmallPtrSet<Instruction *, 4> Defs;
329 SmallPtrSet<Instruction *, 4> Uses;
330 SmallPtrSet<Instruction *, 4> Visited;
331
332 Worklist.push_back(cast<Instruction>(I));
333 while (!Worklist.empty()) {
334 Instruction *II = Worklist.pop_back_val();
335
336 if (!Visited.insert(II).second)
337 continue;
338
339 if (!shouldReplace(II->getType()))
340 continue;
341
342 if (!isCoercionProfitable(II))
343 continue;
344
345 if (PHINode *Phi = dyn_cast<PHINode>(II)) {
346 PhiNodes.insert(Phi);
347 // Collect all the incoming values of problematic PHI nodes.
348 for (Value *V : Phi->incoming_values()) {
349 // Repeat the collection process for newly found PHI nodes.
350 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
351 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
352 Worklist.push_back(OpPhi);
353 continue;
354 }
355
357 // Other incoming value types (e.g. vector literals) are unhandled
358 if (!IncInst && !isa<ConstantAggregateZero>(V))
359 return false;
360
361 // Collect all other incoming values for coercion.
362 if (IncInst)
363 Defs.insert(IncInst);
364 }
365 }
366
367 // Collect all relevant uses.
368 for (User *V : II->users()) {
369 // Repeat the collection process for problematic PHI nodes.
370 if (PHINode *OpPhi = dyn_cast<PHINode>(V)) {
371 if (!PhiNodes.count(OpPhi) && !Visited.count(OpPhi))
372 Worklist.push_back(OpPhi);
373 continue;
374 }
375
376 Instruction *UseInst = cast<Instruction>(V);
377 // Collect all uses of PHINodes and any use the crosses BB boundaries.
378 if (UseInst->getParent() != II->getParent() || isa<PHINode>(II)) {
379 Uses.insert(UseInst);
380 if (!isa<PHINode>(II))
381 Defs.insert(II);
382 }
383 }
384 }
385
386 // Coerce and track the defs.
387 for (Instruction *D : Defs) {
388 if (!ValMap.contains(D)) {
389 BasicBlock::iterator InsertPt = std::next(D->getIterator());
390 Value *ConvertVal = convertToOptType(D, InsertPt);
391 assert(ConvertVal);
392 ValMap[D] = ConvertVal;
393 }
394 }
395
396 // Construct new-typed PHI nodes.
397 for (PHINode *Phi : PhiNodes) {
398 ValMap[Phi] = PHINode::Create(calculateConvertType(Phi->getType()),
399 Phi->getNumIncomingValues(),
400 Phi->getName() + ".tc", Phi->getIterator());
401 }
402
403 // Connect all the PHI nodes with their new incoming values.
404 for (PHINode *Phi : PhiNodes) {
405 PHINode *NewPhi = cast<PHINode>(ValMap[Phi]);
406 bool MissingIncVal = false;
407 for (int I = 0, E = Phi->getNumIncomingValues(); I < E; I++) {
408 Value *IncVal = Phi->getIncomingValue(I);
409 if (isa<ConstantAggregateZero>(IncVal)) {
410 Type *NewType = calculateConvertType(Phi->getType());
411 NewPhi->addIncoming(ConstantInt::get(NewType, 0, false),
412 Phi->getIncomingBlock(I));
413 } else if (Value *Val = ValMap.lookup(IncVal))
414 NewPhi->addIncoming(Val, Phi->getIncomingBlock(I));
415 else
416 MissingIncVal = true;
417 }
418 if (MissingIncVal) {
419 Value *DeadVal = ValMap[Phi];
420 // The coercion chain of the PHI is broken. Delete the Phi
421 // from the ValMap and any connected / user Phis.
422 SmallVector<Value *, 4> PHIWorklist;
423 SmallPtrSet<Value *, 4> VisitedPhis;
424 PHIWorklist.push_back(DeadVal);
425 while (!PHIWorklist.empty()) {
426 Value *NextDeadValue = PHIWorklist.pop_back_val();
427 VisitedPhis.insert(NextDeadValue);
428 auto OriginalPhi =
429 llvm::find_if(PhiNodes, [this, &NextDeadValue](PHINode *CandPhi) {
430 return ValMap[CandPhi] == NextDeadValue;
431 });
432 // This PHI may have already been removed from maps when
433 // unwinding a previous Phi
434 if (OriginalPhi != PhiNodes.end())
435 ValMap.erase(*OriginalPhi);
436
437 DeadInsts.emplace_back(cast<Instruction>(NextDeadValue));
438
439 for (User *U : NextDeadValue->users()) {
440 if (!VisitedPhis.contains(cast<PHINode>(U)))
441 PHIWorklist.push_back(U);
442 }
443 }
444 } else {
445 DeadInsts.emplace_back(cast<Instruction>(Phi));
446 }
447 }
448 // Coerce back to the original type and replace the uses.
449 for (Instruction *U : Uses) {
450 // Replace all converted operands for a use.
451 for (auto [OpIdx, Op] : enumerate(U->operands())) {
452 if (Value *Val = ValMap.lookup(Op)) {
453 Value *NewVal = nullptr;
454 if (BBUseValMap.contains(U->getParent()) &&
455 BBUseValMap[U->getParent()].contains(Val))
456 NewVal = BBUseValMap[U->getParent()][Val];
457 else {
458 BasicBlock::iterator InsertPt = U->getParent()->getFirstNonPHIIt();
459 // We may pick up ops that were previously converted for users in
460 // other blocks. If there is an originally typed definition of the Op
461 // already in this block, simply reuse it.
463 U->getParent() == cast<Instruction>(Op)->getParent()) {
464 NewVal = Op;
465 } else {
466 NewVal =
467 convertFromOptType(Op->getType(), cast<Instruction>(ValMap[Op]),
468 InsertPt, U->getParent());
469 BBUseValMap[U->getParent()][ValMap[Op]] = NewVal;
470 }
471 }
472 assert(NewVal);
473 U->setOperand(OpIdx, NewVal);
474 }
475 }
476 }
477
478 return true;
479}
480
481bool AMDGPULateCodeGenPrepare::canWidenScalarExtLoad(LoadInst &LI) const {
482 unsigned AS = LI.getPointerAddressSpace();
483 // Skip non-constant address space.
484 if (AS != AMDGPUAS::CONSTANT_ADDRESS &&
486 return false;
487 // Skip non-simple loads.
488 if (!LI.isSimple())
489 return false;
490 Type *Ty = LI.getType();
491 // Skip aggregate types.
492 if (Ty->isAggregateType())
493 return false;
494 unsigned TySize = DL.getTypeStoreSize(Ty);
495 // Only handle sub-DWORD loads.
496 if (TySize >= 4)
497 return false;
498 // That load must be at least naturally aligned.
499 if (LI.getAlign() < DL.getABITypeAlign(Ty))
500 return false;
501 // It should be uniform, i.e. a scalar load.
502 return UA.isUniformAtDef(&LI);
503}
504
505bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) {
506 if (!WidenLoads)
507 return false;
508
509 // Skip if that load is already aligned on DWORD at least as it's handled in
510 // SDAG.
511 if (LI.getAlign() >= 4)
512 return false;
513
514 if (!canWidenScalarExtLoad(LI))
515 return false;
516
517 int64_t Offset = 0;
518 auto *Base =
520
521 int64_t Adjust = Offset & 0x3;
522 int64_t AccessOffset = Offset - Adjust;
523 if (AccessOffset < 0 || !isSafeToWidenLoad(Base, AccessOffset + 4, &LI))
524 return false;
525
526 IRBuilder<> IRB(&LI);
527 IRB.SetCurrentDebugLocation(LI.getDebugLoc());
528
529 unsigned LdBits = DL.getTypeStoreSizeInBits(LI.getType());
530 auto *IntNTy = Type::getIntNTy(LI.getContext(), LdBits);
531
532 auto *NewPtr = IRB.CreateConstGEP1_64(
533 IRB.getInt8Ty(),
534 IRB.CreateAddrSpaceCast(Base, LI.getPointerOperand()->getType()),
535 Offset - Adjust);
536
537 LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4));
539
540 unsigned ShAmt = Adjust * 8;
541 Value *Shifted = ShAmt ? IRB.CreateLShr(NewLd, ShAmt) : NewLd;
542 Value *NewVal = IRB.CreateBitCast(
543 IRB.CreateTrunc(Shifted, DL.typeSizeEqualsStoreSize(LI.getType())
544 ? IntNTy
545 : LI.getType()),
546 LI.getType());
547 LI.replaceAllUsesWith(NewVal);
548 DeadInsts.emplace_back(&LI);
549
550 return true;
551}
552
553PreservedAnalyses
555 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
556 AssumptionCache &AC = FAM.getResult<AssumptionAnalysis>(F);
557 UniformityInfo &UI = FAM.getResult<UniformityInfoAnalysis>(F);
558
559 bool Changed = AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
560
561 if (!Changed)
562 return PreservedAnalyses::all();
565 return PA;
566}
567
569public:
570 static char ID;
571
573
574 StringRef getPassName() const override {
575 return "AMDGPU IR late optimizations";
576 }
577
578 void getAnalysisUsage(AnalysisUsage &AU) const override {
582 // Invalidates UniformityInfo
583 AU.setPreservesCFG();
584 }
585
586 bool runOnFunction(Function &F) override;
587};
588
590 if (skipFunction(F))
591 return false;
592
594 const TargetMachine &TM = TPC.getTM<TargetMachine>();
595 const GCNSubtarget &ST = TM.getSubtarget<GCNSubtarget>(F);
596
597 AssumptionCache &AC =
598 getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
599 UniformityInfo &UI =
600 getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo();
601
602 return AMDGPULateCodeGenPrepare(F, ST, &AC, UI).run();
603}
604
606 "AMDGPU IR late optimizations", false, false)
611 "AMDGPU IR late optimizations", false, false)
612
614
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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 cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::values(clEnumValN(DefaultIT, "arm-default-it", "Generate any type of IT block"), clEnumValN(RestrictedIT, "arm-restrict-it", "Disallow complex IT blocks")))
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool runOnFunction(Function &F, bool PostInlining)
#define DEBUG_TYPE
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Machine Check Debug Module
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
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> 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 &)
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:275
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.
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
Definition DenseMap.h:250
bool erase(const KeyT &Val)
Definition DenseMap.h:377
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Definition DenseMap.h:214
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
FunctionPass(char &pid)
Definition Pass.h:316
bool skipFunction(const Function &F) const
Optional passes call this function to check whether the pass should be skipped.
Definition Pass.cpp:193
bool isUniformAtDef(ConstValueRefT V) const
Whether V is uniform/non-divergent at its definition.
Base class for instruction visitors.
Definition InstVisitor.h:78
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition Type.cpp:348
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
Value * getPointerOperand()
bool isSimple() const
Align getAlign() const
Return the alignment of the access that is being performed.
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...
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
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
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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.
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.
bool isAggregateType() const
Return true if the type is an aggregate type.
Definition Type.h:319
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition Type.h:130
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Definition Type.cpp:232
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:257
Analysis pass which computes UniformityInfo.
Legacy analysis pass which computes a CycleInfo.
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:553
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:258
iterator_range< user_iterator > users()
Definition Value.h:426
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
Type * getElementType() const
constexpr ScalarTy getFixedValue() const
Definition TypeSize.h:200
const ParentTy * getParent() const
Definition ilist_node.h:34
Changed
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void copyMetadataForWidenedLoad(LoadInst &Dest, const LoadInst &Source)
initializer< Ty > init(const Ty &Val)
DXILDebugInfoMap run(Module &M)
NodeAddr< PhiNode * > Phi
Definition RDFGraph.h:390
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
@ Offset
Definition DWP.cpp:578
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:2554
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
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:633
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
auto reverse(ContainerTy &&C)
Definition STLExtras.h:407
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
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
DWARFExpression::Operation Op
LLVM_ABI bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, Align Alignment, const SimplifyQuery &Q, bool IgnoreFree=false)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested.
Definition Loads.cpp:244
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:550
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
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:1772
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
FunctionPass * createAMDGPULateCodeGenPrepareLegacyPass()
DenseMap< const Value *, Value * > ValueToValueMap
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.