LLVM 23.0.0git
BottomUpVec.cpp
Go to the documentation of this file.
1//===- BottomUpVec.cpp - A bottom-up vectorizer pass ----------------------===//
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
18
19namespace llvm {
20
21#ifndef NDEBUG
22static cl::opt<bool>
23 AlwaysVerify("sbvec-always-verify", cl::init(false), cl::Hidden,
24 cl::desc("Helps find bugs by verifying the IR whenever we "
25 "emit new instructions (*very* expensive)."));
26#endif // NDEBUG
27
28static constexpr unsigned long StopAtDisabled =
29 std::numeric_limits<unsigned long>::max();
32 cl::desc("Vectorize if the invocation count is < than this. 0 "
33 "disables vectorization."));
34
35static constexpr unsigned long StopBundleDisabled =
36 std::numeric_limits<unsigned long>::max();
39 cl::desc("Vectorize up to this many bundles."));
40
41namespace sandboxir {
42
44 unsigned OpIdx) {
46 for (Value *BndlV : Bndl) {
47 auto *BndlI = cast<Instruction>(BndlV);
48 Operands.push_back(BndlI->getOperand(OpIdx));
49 }
50 return Operands;
51}
52
53/// \Returns the BB iterator after the lowest instruction in \p Vals, or the top
54/// of BB if no instruction found in \p Vals.
56 BasicBlock *BB) {
57 auto *BotI = VecUtils::getLastPHIOrSelf(VecUtils::getLowest(Vals, BB));
58 if (BotI == nullptr)
59 // We are using BB->begin() (or after PHIs) as the fallback insert point.
60 return BB->empty()
61 ? BB->begin()
62 : std::next(
63 VecUtils::getLastPHIOrSelf(&*BB->begin())->getIterator());
64 return std::next(BotI->getIterator());
65}
66
67Value *BottomUpVec::createVectorInstr(ArrayRef<Value *> Bndl,
68 ArrayRef<Value *> Operands) {
69 auto CreateVectorInstr = [](ArrayRef<Value *> Bndl,
70 ArrayRef<Value *> Operands) -> Value * {
71 assert(all_of(Bndl, [](auto *V) { return isa<Instruction>(V); }) &&
72 "Expect Instructions!");
73 auto &Ctx = Bndl[0]->getContext();
74
75 Type *ScalarTy = VecUtils::getElementType(Utils::getExpectedType(Bndl[0]));
76 auto *VecTy = VecUtils::getWideType(ScalarTy, VecUtils::getNumLanes(Bndl));
77
79 Bndl, cast<Instruction>(Bndl[0])->getParent());
80
81 auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
82 switch (Opcode) {
83 case Instruction::Opcode::ZExt:
84 case Instruction::Opcode::SExt:
85 case Instruction::Opcode::FPToUI:
86 case Instruction::Opcode::FPToSI:
87 case Instruction::Opcode::FPExt:
88 case Instruction::Opcode::PtrToInt:
89 case Instruction::Opcode::IntToPtr:
90 case Instruction::Opcode::SIToFP:
91 case Instruction::Opcode::UIToFP:
92 case Instruction::Opcode::Trunc:
93 case Instruction::Opcode::FPTrunc:
94 case Instruction::Opcode::BitCast: {
95 assert(Operands.size() == 1u && "Casts are unary!");
96 return CastInst::create(VecTy, Opcode, Operands[0], WhereIt, Ctx,
97 "VCast");
98 }
99 case Instruction::Opcode::FCmp:
100 case Instruction::Opcode::ICmp: {
101 auto Pred = cast<CmpInst>(Bndl[0])->getPredicate();
103 [Pred](auto *SBV) {
104 return cast<CmpInst>(SBV)->getPredicate() == Pred;
105 }) &&
106 "Expected same predicate across bundle.");
107 return CmpInst::create(Pred, Operands[0], Operands[1], WhereIt, Ctx,
108 "VCmp");
109 }
110 case Instruction::Opcode::Select: {
111 return SelectInst::create(Operands[0], Operands[1], Operands[2], WhereIt,
112 Ctx, "Vec");
113 }
114 case Instruction::Opcode::FNeg: {
115 auto *UOp0 = cast<UnaryOperator>(Bndl[0]);
116 auto OpC = UOp0->getOpcode();
117 return UnaryOperator::createWithCopiedFlags(OpC, Operands[0], UOp0,
118 WhereIt, Ctx, "Vec");
119 }
120 case Instruction::Opcode::Add:
121 case Instruction::Opcode::FAdd:
122 case Instruction::Opcode::Sub:
123 case Instruction::Opcode::FSub:
124 case Instruction::Opcode::Mul:
125 case Instruction::Opcode::FMul:
126 case Instruction::Opcode::UDiv:
127 case Instruction::Opcode::SDiv:
128 case Instruction::Opcode::FDiv:
129 case Instruction::Opcode::URem:
130 case Instruction::Opcode::SRem:
131 case Instruction::Opcode::FRem:
132 case Instruction::Opcode::Shl:
133 case Instruction::Opcode::LShr:
134 case Instruction::Opcode::AShr:
135 case Instruction::Opcode::And:
136 case Instruction::Opcode::Or:
137 case Instruction::Opcode::Xor: {
138 auto *BinOp0 = cast<BinaryOperator>(Bndl[0]);
139 auto *LHS = Operands[0];
140 auto *RHS = Operands[1];
142 BinOp0->getOpcode(), LHS, RHS, BinOp0, WhereIt, Ctx, "Vec");
143 }
144 case Instruction::Opcode::Load: {
145 auto *Ld0 = cast<LoadInst>(Bndl[0]);
146 Value *Ptr = Ld0->getPointerOperand();
147 return LoadInst::create(VecTy, Ptr, Ld0->getAlign(), WhereIt, Ctx,
148 "VecL");
149 }
150 case Instruction::Opcode::Store: {
151 auto Align = cast<StoreInst>(Bndl[0])->getAlign();
152 Value *Val = Operands[0];
153 Value *Ptr = Operands[1];
154 return StoreInst::create(Val, Ptr, Align, WhereIt, Ctx);
155 }
156 case Instruction::Opcode::UncondBr:
157 case Instruction::Opcode::CondBr:
158 case Instruction::Opcode::Ret:
159 case Instruction::Opcode::PHI:
160 case Instruction::Opcode::AddrSpaceCast:
161 case Instruction::Opcode::Call:
162 case Instruction::Opcode::GetElementPtr:
163 llvm_unreachable("Unimplemented");
164 break;
165 default:
166 llvm_unreachable("Unimplemented");
167 break;
168 }
169 llvm_unreachable("Missing switch case!");
170 // TODO: Propagate debug info.
171 };
172
173 auto *NewI = CreateVectorInstr(Bndl, Operands);
174 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "New instr: " << *NewI << "\n");
175 return NewI;
176}
177
178void BottomUpVec::tryEraseDeadInstrs() {
179 DenseMap<BasicBlock *, SmallVector<Instruction *>> SortedDeadInstrCandidates;
180 // The dead instrs could span BBs, so we need to collect and sort them per BB.
181 for (auto *DeadI : DeadInstrCandidates)
182 SortedDeadInstrCandidates[DeadI->getParent()].push_back(DeadI);
183 for (auto &Pair : SortedDeadInstrCandidates)
184 sort(Pair.second,
185 [](Instruction *I1, Instruction *I2) { return I1->comesBefore(I2); });
186 for (const auto &Pair : SortedDeadInstrCandidates) {
187 for (Instruction *I : reverse(Pair.second)) {
188 if (I->hasNUses(0)) {
189 // Erase the dead instructions bottom-to-top.
190 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "Erase dead: " << *I << "\n");
191 I->eraseFromParent();
192 }
193 }
194 }
195 DeadInstrCandidates.clear();
196}
197
198Value *BottomUpVec::createShuffle(Value *VecOp, const ShuffleMask &Mask,
199 BasicBlock *UserBB) {
200 BasicBlock::iterator WhereIt = getInsertPointAfterInstrs({VecOp}, UserBB);
201 return ShuffleVectorInst::create(VecOp, VecOp, Mask, WhereIt,
202 VecOp->getContext(), "VShuf");
203}
204
205Value *BottomUpVec::createPack(ArrayRef<Value *> ToPack, BasicBlock *UserBB) {
206 BasicBlock::iterator WhereIt = getInsertPointAfterInstrs(ToPack, UserBB);
207
208 Type *ScalarTy = VecUtils::getCommonScalarType(ToPack);
209 unsigned Lanes = VecUtils::getNumLanes(ToPack);
210 Type *VecTy = VecUtils::getWideType(ScalarTy, Lanes);
211
212 // Create a series of pack instructions.
213 Value *LastInsert = PoisonValue::get(VecTy);
214
215 Context &Ctx = ToPack[0]->getContext();
216
217 unsigned InsertIdx = 0;
218 for (Value *Elm : ToPack) {
219 // An element can be either scalar or vector. We need to generate different
220 // IR for each case.
221 if (Elm->getType()->isVectorTy()) {
222 unsigned NumElms =
223 cast<FixedVectorType>(Elm->getType())->getNumElements();
224 for (auto ExtrLane : seq<int>(0, NumElms)) {
225 // We generate extract-insert pairs, for each lane in `Elm`.
226 Constant *ExtrLaneC =
228 // This may return a Constant if Elm is a Constant.
229 auto *ExtrI =
230 ExtractElementInst::create(Elm, ExtrLaneC, WhereIt, Ctx, "VPack");
231 if (!isa<Constant>(ExtrI))
232 WhereIt = std::next(cast<Instruction>(ExtrI)->getIterator());
233 Constant *InsertLaneC =
234 ConstantInt::getSigned(Type::getInt32Ty(Ctx), InsertIdx++);
235 // This may also return a Constant if ExtrI is a Constant.
236 auto *InsertI = InsertElementInst::create(
237 LastInsert, ExtrI, InsertLaneC, WhereIt, Ctx, "VPack");
238 LastInsert = InsertI;
239 if (!isa<Constant>(InsertI))
240 WhereIt = std::next(cast<Instruction>(LastInsert)->getIterator());
241 }
242 } else {
243 Constant *InsertLaneC =
244 ConstantInt::getSigned(Type::getInt32Ty(Ctx), InsertIdx++);
245 // This may be folded into a Constant if LastInsert is a Constant. In
246 // that case we only collect the last constant.
247 LastInsert = InsertElementInst::create(LastInsert, Elm, InsertLaneC,
248 WhereIt, Ctx, "Pack");
249 if (auto *NewI = dyn_cast<Instruction>(LastInsert))
250 WhereIt = std::next(NewI->getIterator());
251 }
252 }
253 return LastInsert;
254}
255
256void BottomUpVec::collectPotentiallyDeadInstrs(ArrayRef<Value *> Bndl) {
257 for (Value *V : Bndl)
258 DeadInstrCandidates.insert(cast<Instruction>(V));
259 // Also collect the GEPs of vectorized loads and stores.
260 auto Opcode = cast<Instruction>(Bndl[0])->getOpcode();
261 switch (Opcode) {
262 case Instruction::Opcode::Load: {
263 for (Value *V : drop_begin(Bndl))
264 if (auto *Ptr =
266 DeadInstrCandidates.insert(Ptr);
267 break;
268 }
269 case Instruction::Opcode::Store: {
270 for (Value *V : drop_begin(Bndl))
271 if (auto *Ptr =
273 DeadInstrCandidates.insert(Ptr);
274 break;
275 }
276 default:
277 break;
278 }
279}
280
281Action *BottomUpVec::vectorizeRec(ArrayRef<Value *> Bndl,
282 ArrayRef<Value *> UserBndl, unsigned Depth,
283 LegalityAnalysis &Legality) {
284 bool StopForDebug =
285 DebugBndlCnt++ >= StopBundle && StopBundle != StopBundleDisabled;
286 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "canVectorize() Bundle:\n";
287 VecUtils::dump(Bndl));
288 const auto &LegalityRes = StopForDebug ? Legality.getForcedPackForDebugging()
289 : Legality.canVectorize(Bndl);
290 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "Legality: " << LegalityRes << "\n");
291 auto ActionPtr =
292 std::make_unique<Action>(&LegalityRes, Bndl, UserBndl, Depth);
293 SmallVector<Action *> Operands;
294 switch (LegalityRes.getSubclassID()) {
296 auto *I = cast<Instruction>(Bndl[0]);
297 switch (I->getOpcode()) {
298 case Instruction::Opcode::Load:
299 break;
300 case Instruction::Opcode::Store: {
301 // Don't recurse towards the pointer operand.
302 Action *OpA =
303 vectorizeRec(getOperand(Bndl, 0), Bndl, Depth + 1, Legality);
304 Operands.push_back(OpA);
305 break;
306 }
307 default:
308 // Visit all operands.
309 for (auto OpIdx : seq<unsigned>(I->getNumOperands())) {
310 Action *OpA =
311 vectorizeRec(getOperand(Bndl, OpIdx), Bndl, Depth + 1, Legality);
312 Operands.push_back(OpA);
313 }
314 break;
315 }
316 // Update the maps to mark Bndl as "vectorized".
317 IMaps->registerVector(Bndl, ActionPtr.get());
318 break;
319 }
324 break;
325 }
326 // Create actions in post-order.
327 ActionPtr->Operands = std::move(Operands);
328 auto *Action = ActionPtr.get();
329 Actions.push_back(std::move(ActionPtr));
330 return Action;
331}
332
333#ifndef NDEBUG
334void BottomUpVec::ActionsVector::print(raw_ostream &OS) const {
335 for (auto [Idx, Action] : enumerate(Actions)) {
336 Action->print(OS);
337 OS << "\n";
338 }
339}
340void BottomUpVec::ActionsVector::dump() const { print(dbgs()); }
341#endif // NDEBUG
342
343Value *BottomUpVec::emitVectors() {
344 Value *NewVec = nullptr;
345 for (const auto &ActionPtr : Actions) {
346 ArrayRef<Value *> Bndl = ActionPtr->Bndl;
347 ArrayRef<Value *> UserBndl = ActionPtr->UserBndl;
348 const LegalityResult &LegalityRes = *ActionPtr->LegalityRes;
349 unsigned Depth = ActionPtr->Depth;
350 auto *UserBB = !UserBndl.empty()
351 ? cast<Instruction>(UserBndl.front())->getParent()
352 : cast<Instruction>(Bndl[0])->getParent();
353
354 switch (LegalityRes.getSubclassID()) {
356 auto *I = cast<Instruction>(Bndl[0]);
357 SmallVector<Value *, 2> VecOperands;
358 switch (I->getOpcode()) {
359 case Instruction::Opcode::Load:
360 VecOperands.push_back(cast<LoadInst>(I)->getPointerOperand());
361 break;
362 case Instruction::Opcode::Store: {
363 VecOperands.push_back(ActionPtr->Operands[0]->Vec);
364 VecOperands.push_back(cast<StoreInst>(I)->getPointerOperand());
365 break;
366 }
367 default:
368 // Visit all operands.
369 for (Action *OpA : ActionPtr->Operands) {
370 auto *VecOp = OpA->Vec;
371 VecOperands.push_back(VecOp);
372 }
373 break;
374 }
375 NewVec = createVectorInstr(ActionPtr->Bndl, VecOperands);
376 // Collect any potentially dead scalar instructions, including the
377 // original scalars and pointer operands of loads/stores.
378 if (NewVec != nullptr)
379 collectPotentiallyDeadInstrs(Bndl);
380 break;
381 }
383 NewVec = cast<DiamondReuse>(LegalityRes).getVector()->Vec;
384 break;
385 }
387 auto *VecOp = cast<DiamondReuseWithShuffle>(LegalityRes).getVector()->Vec;
388 const ShuffleMask &Mask =
389 cast<DiamondReuseWithShuffle>(LegalityRes).getMask();
390 NewVec = createShuffle(VecOp, Mask, UserBB);
391 assert(NewVec->getType() == VecOp->getType() &&
392 "Expected same type! Bad mask ?");
393 break;
394 }
396 const auto &Descr =
397 cast<DiamondReuseMultiInput>(LegalityRes).getCollectDescr();
398 Type *ResTy = VecUtils::getWideType(Bndl[0]->getType(), Bndl.size());
399
400 // TODO: Try to get WhereIt without creating a vector.
401 SmallVector<Value *, 4> DescrInstrs;
402 for (const auto &ElmDescr : Descr.getDescrs()) {
403 auto *V = ElmDescr.needsExtract() ? ElmDescr.getValue()->Vec
404 : ElmDescr.getScalar();
405 if (auto *I = dyn_cast<Instruction>(V))
406 DescrInstrs.push_back(I);
407 }
408 BasicBlock::iterator WhereIt =
409 getInsertPointAfterInstrs(DescrInstrs, UserBB);
410
411 Value *LastV = PoisonValue::get(ResTy);
412 Context &Ctx = LastV->getContext();
413 unsigned Lane = 0;
414 for (const auto &ElmDescr : Descr.getDescrs()) {
415 Value *VecOp = nullptr;
416 Value *ValueToInsert;
417 if (ElmDescr.needsExtract()) {
418 VecOp = ElmDescr.getValue()->Vec;
419 ConstantInt *IdxC =
420 ConstantInt::get(Type::getInt32Ty(Ctx), ElmDescr.getExtractIdx());
421 ValueToInsert = ExtractElementInst::create(
422 VecOp, IdxC, WhereIt, VecOp->getContext(), "VExt");
423 } else {
424 ValueToInsert = ElmDescr.getScalar();
425 }
426 auto NumLanesToInsert = VecUtils::getNumLanes(ValueToInsert);
427 if (NumLanesToInsert == 1) {
428 // If we are inserting a scalar element then we need a single insert.
429 // %VIns = insert %DstVec, %SrcScalar, Lane
430 ConstantInt *LaneC = ConstantInt::get(Type::getInt32Ty(Ctx), Lane);
431 LastV = InsertElementInst::create(LastV, ValueToInsert, LaneC,
432 WhereIt, Ctx, "VIns");
433 } else {
434 // If we are inserting a vector element then we need to extract and
435 // insert each vector element one by one with a chain of extracts and
436 // inserts, for example:
437 // %VExt0 = extract %SrcVec, 0
438 // %VIns0 = insert %DstVec, %Vect0, Lane + 0
439 // %VExt1 = extract %SrcVec, 1
440 // %VIns1 = insert %VIns0, %Vect0, Lane + 1
441 for (unsigned LnCnt = 0; LnCnt != NumLanesToInsert; ++LnCnt) {
442 auto *ExtrIdxC = ConstantInt::get(Type::getInt32Ty(Ctx), LnCnt);
443 auto *ExtrI = ExtractElementInst::create(ValueToInsert, ExtrIdxC,
444 WhereIt, Ctx, "VExt");
445 unsigned InsLane = Lane + LnCnt;
446 auto *InsLaneC = ConstantInt::get(Type::getInt32Ty(Ctx), InsLane);
447 LastV = InsertElementInst::create(LastV, ExtrI, InsLaneC, WhereIt,
448 Ctx, "VIns");
449 }
450 }
451 Lane += NumLanesToInsert;
452 }
453 NewVec = LastV;
454 break;
455 }
457 // If we can't vectorize the seeds then just return.
458 if (Depth == 0)
459 return nullptr;
460 NewVec = createPack(Bndl, UserBB);
461 break;
462 }
463 }
464 if (NewVec != nullptr) {
465 Change = true;
466 ActionPtr->Vec = NewVec;
467 }
468#ifndef NDEBUG
469 if (AlwaysVerify) {
470 // This helps find broken IR by constantly verifying the function. Note
471 // that this is very expensive and should only be used for debugging.
472 Instruction *I0 = isa<Instruction>(Bndl[0])
473 ? cast<Instruction>(Bndl[0])
474 : cast<Instruction>(UserBndl[0]);
475 assert(!Utils::verifyFunction(I0->getParent()->getParent(), dbgs()) &&
476 "Broken function!");
477 }
478#endif // NDEBUG
479 }
480 return NewVec;
481}
482
483bool BottomUpVec::tryVectorize(ArrayRef<Value *> Bndl,
484 LegalityAnalysis &Legality) {
485 Change = false;
486 if (LLVM_UNLIKELY(BottomUpInvocationCnt++ >= StopAt &&
488 return false;
489 DeadInstrCandidates.clear();
490 Legality.clear();
491 Actions.clear();
492 DebugBndlCnt = 0;
493 vectorizeRec(Bndl, {}, /*Depth=*/0, Legality);
494 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "BottomUpVec: Vectorization Actions:\n";
495 Actions.dump());
496 emitVectors();
497 tryEraseDeadInstrs();
498 return Change;
499}
500
502 const auto &SeedSlice = Rgn.getAux();
503 assert(SeedSlice.size() >= 2 && "Bad slice!");
504 Function &F = *SeedSlice[0]->getParent()->getParent();
505 IMaps = std::make_unique<InstrMaps>();
506 LegalityAnalysis Legality(A.getAA(), A.getScalarEvolution(),
507 F.getParent()->getDataLayout(), F.getContext(),
508 *IMaps);
509
510 // TODO: Refactor to remove the unnecessary copy to SeedSliceVals.
511 SmallVector<Value *> SeedSliceVals(SeedSlice.begin(), SeedSlice.end());
512 // Try to vectorize starting from the seed slice. The returned value
513 // is true if we found vectorizable code and generated some vector
514 // code for it. It does not mean that the code is profitable.
515 return tryVectorize(SeedSliceVals, Legality);
516}
517
518} // namespace sandboxir
519} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_UNLIKELY(EXPR)
Definition Compiler.h:336
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
MachineInstr unsigned OpIdx
This file defines the SmallVector class.
#define LLVM_DEBUG(...)
Definition Debug.h:114
static SymbolRef::Type getType(const Symbol *Sym)
Definition TapiFile.cpp:39
#define DEBUG_PREFIX
Definition Debug.h:19
Value * RHS
Value * LHS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
size - Get the array size.
Definition ArrayRef.h:142
iterator begin()
Instruction iterator methods.
Definition BasicBlock.h:449
bool empty() const
Definition BasicBlock.h:471
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
Definition Value.h:75
static LLVM_ABI Value * createWithCopiedFlags(Instruction::Opcode Op, Value *LHS, Value *RHS, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
bool runOnRegion(Region &Rgn, const Analyses &A) final
\Returns true if it modifies R.
static LLVM_ABI Value * create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Value * create(Predicate Pred, Value *S1, Value *S2, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition Constant.cpp:48
static LLVM_ABI ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
Definition Constant.cpp:56
static LLVM_ABI Value * create(Value *Vec, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Value * create(Value *Vec, Value *NewElt, Value *Idx, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Performs the legality analysis and returns a LegalityResult object.
Definition Legality.h:318
static LLVM_ABI LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name="")
virtual void print(raw_ostream &OS) const
Definition Pass.h:67
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition Constant.cpp:259
The main job of the Region is to point to new instructions generated by vectorization passes.
Definition Region.h:96
const SmallVector< Instruction * > & getAux() const
\Returns the auxiliary vector.
Definition Region.h:156
static LLVM_ABI Value * create(Value *Cond, Value *True, Value *False, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Value * create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
static LLVM_ABI IntegerType * getInt32Ty(Context &Ctx)
Definition Type.cpp:21
static LLVM_ABI Value * createWithCopiedFlags(Instruction::Opcode Op, Value *OpV, Value *CopyFrom, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
Definition Utils.h:32
static bool verifyFunction(const Function *F, raw_ostream &OS)
Equivalent to llvm::verifyFunction().
Definition Utils.h:130
A SandboxIR Value has users. This is the base class.
Definition Value.h:68
static Instruction * getLowest(ArrayRef< Instruction * > Instrs)
\Returns the instruction in Instrs that is lowest in the BB.
Definition VecUtils.h:124
static Type * getCommonScalarType(ArrayRef< Value * > Bndl)
Similar to tryGetCommonScalarType() but will assert that there is a common type.
Definition VecUtils.h:191
static Instruction * getLastPHIOrSelf(Instruction *I)
If I is not a PHI it returns it.
Definition VecUtils.h:164
static unsigned getNumLanes(Type *Ty)
\Returns the number of vector lanes of Ty or 1 if not a vector.
Definition VecUtils.h:91
static LLVM_DUMP_METHOD void dump(ArrayRef< Value * > Bndl)
Helper dump function for debugging.
Definition VecUtils.cpp:28
static Type * getWideType(Type *ElemTy, unsigned NumElts)
\Returns <NumElts x ElemTy>.
Definition VecUtils.h:114
static Type * getElementType(Type *Ty)
Returns Ty if scalar or its element type if vector.
Definition VecUtils.h:51
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
initializer< Ty > init(const Ty &Val)
LLVM_ABI Function * getParent() const
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
Definition BasicBlock.h:75
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
static BasicBlock::iterator getInsertPointAfterInstrs(ArrayRef< Value * > Vals, BasicBlock *BB)
\Returns the BB iterator after the lowest instruction in Vals, or the top of BB if no instruction fou...
static SmallVector< Value *, 4 > getOperand(ArrayRef< Value * > Bndl, unsigned OpIdx)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition STLExtras.h:316
FunctionAddr VTableAddr Value
Definition InstrProf.h:137
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1739
static cl::opt< unsigned long > StopAt("sbvec-stop-at", cl::init(StopAtDisabled), cl::Hidden, cl::desc("Vectorize if the invocation count is < than this. 0 " "disables vectorization."))
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
static constexpr unsigned long StopBundleDisabled
static cl::opt< unsigned long > StopBundle("sbvec-stop-bndl", cl::init(StopBundleDisabled), cl::Hidden, cl::desc("Vectorize up to this many bundles."))
const Value * getPointerOperand(const Value *V)
A helper function that returns the pointer operand of a load, store or GEP instruction.
auto reverse(ContainerTy &&C)
Definition STLExtras.h:408
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1636
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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
ArrayRef(const T &OneElt) -> ArrayRef< T >
static constexpr unsigned long StopAtDisabled
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
static cl::opt< bool > AlwaysVerify("sbvec-always-verify", cl::init(false), cl::Hidden, cl::desc("Helps find bugs by verifying the IR whenever we " "emit new instructions (*very* expensive)."))
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Definition Sequence.h:305