LLVM 24.0.0git
LoadStoreVec.cpp
Go to the documentation of this file.
1//===- LoadStoreVec.cpp - Vectorizer pass short load-store chains ---------===//
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
11#include "llvm/ADT/STLExtras.h"
21
22namespace llvm {
23
24namespace sandboxir {
25
26#define DEBUG_PREFIX_LOCAL DEBUG_PREFIX "LoadStoreVec: "
27
28/// \returns true if \p Ty is a pointer, or a vector of pointers, in a
29/// non-integral address space, which has no stable integer representation.
30static bool isNonIntegralPtr(Type *Ty, const DataLayout &DL) {
31 Type *ScalarTy = Ty->getScalarType();
32 return ScalarTy->isPointerTy() &&
33 DL.isNonIntegralAddressSpace(ScalarTy->getPointerAddressSpace());
34}
35
36std::optional<Type *> LoadStoreVec::canVectorize(BndlRef<Instruction *> Bndl) {
37 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "canVectorize() Bundle:\n";
38 VecUtils::dump(Bndl));
39 const auto &LegalityRes = Legality->canVectorizeLSV(Bndl);
40 LLVM_DEBUG(dbgs() << DEBUG_PREFIX << "Legality: " << LegalityRes << "\n");
41
42 if (LegalityRes.getSubclassID() != LegalityResultID::Widen)
43 return std::nullopt;
45}
46
47void LoadStoreVec::saveIR(Region &R) {
48 Rgn = &R;
49 const auto &SB = cast<RegionWithScore>(Rgn)->getScoreboard();
50 CostBefore = SB.getAfterCost() - SB.getBeforeCost();
51 Rgn->getContext().save();
52}
53
54bool LoadStoreVec::acceptOrRevert() {
55 const auto &SB = cast<RegionWithScore>(*Rgn).getScoreboard();
56 InstructionCost CostAfter = SB.getAfterCost() - SB.getBeforeCost();
57 InstructionCost CostGain = CostAfter - CostBefore;
58 LLVM_DEBUG(dbgs() << DEBUG_PREFIX_LOCAL << "CostGain=" << CostGain
59 << " (After=" << CostAfter << " Before=" << CostBefore
60 << ")\n");
61 const VectorizeOptions &Opts = getVectorizeOptions(*Ctx);
62 if (CostGain > Opts.sbvec_cost_threshold) {
63 LLVM_DEBUG(dbgs() << DEBUG_PREFIX_LOCAL << "Not profitable, reverting.\n");
64 Ctx->revert();
65 return false;
66 }
67 LLVM_DEBUG(dbgs() << DEBUG_PREFIX_LOCAL << "Profitable accepting.\n");
68 Ctx->accept();
69 return true;
70}
71
72/// \returns \p ElemTy if \p N is 1, otherwise < \p N x \p ElemTy >.
73static Type *getWidenedType(Type *ElemTy, unsigned N) {
74 assert(!ElemTy->isVectorTy() && "Expected a scalar element type!");
75 return N == 1 ? ElemTy : FixedVectorType::get(ElemTy, N);
76}
77
78template <typename TypeRangeT>
79bool LoadStoreVec::canUnpack(FixedVectorType *FromTy, TypeRangeT ToTypes) {
80 Type *VecElemTy = FromTy->getElementType();
81 return all_of(ToTypes, [this, VecElemTy](Type *ToTy) {
82 unsigned NumElems =
83 Utils::getNumBits(ToTy, *DL) / Utils::getNumBits(VecElemTy, *DL);
85 getWidenedType(VecElemTy, NumElems), ToTy, *DL);
86 });
87}
88
89void LoadStoreVec::unpackIfNeeded(LoadInst *VecLoad,
90 BndlRef<Instruction *> OrigLoads) {
91 Type *VecElemTy = cast<FixedVectorType>(VecLoad->getType())->getElementType();
92 BasicBlock::iterator WhereIt = std::next(VecLoad->getIterator());
93 unsigned Lane = 0;
94 for (Instruction *I : OrigLoads) {
95 auto *Orig = cast<LoadInst>(I);
96 unsigned NumElems = Utils::getNumBits(Orig->getType(), *DL) /
97 Utils::getNumBits(VecElemTy, *DL);
98 Type *LanesTy = getWidenedType(VecElemTy, NumElems);
99 if (!Orig->hasNUses(0)) {
100 Value *Unpacked = VecUtils::unpack(VecLoad, LanesTy, Lane, WhereIt);
102 Unpacked, Orig->getType(), WhereIt, *Ctx, *DL);
103 Orig->replaceAllUsesWith(Unpacked);
104 }
105 Lane += VecUtils::getNumLanes(LanesTy);
106 }
107}
108
109LoadInst *LoadStoreVec::createVectorLoad(BndlRef<Instruction *> Loads) {
111 Value *LdPtr = cast<LoadInst>(Loads[0])->getPointerOperand();
112 Align LdAlign = VecUtils::getVecAlignment(Loads);
113 auto LdWhereIt = std::next(VecUtils::getLowest(Loads)->getIterator());
114 auto *VecL =
115 LoadInst::create(Ty, LdPtr, LdAlign, LdWhereIt, *Ctx, "VecIinitL");
116 Utils::propagateMetadata(VecL, Loads);
117 return VecL;
118}
119
121 const DataLayout &DL) {
122 return !isNonIntegralPtr(SrcTy, DL) && !isNonIntegralPtr(DestTy, DL);
123}
124
125Type *SameSizeReinterpret::getIntTypeFor(Type *Ty, const DataLayout &DL) {
126 Context &Ctx = Ty->getContext();
127 if (auto *VecTy = dyn_cast<FixedVectorType>(Ty)) {
128 auto *ElmIntTy =
129 IntegerType::get(Ctx, Utils::getNumBits(VecTy->getElementType(), DL));
130 return FixedVectorType::get(ElmIntTy, VecTy->getNumElements());
131 }
132 return IntegerType::get(Ctx, Utils::getNumBits(Ty, DL));
133}
134
136SameSizeReinterpret::getCastChain(Type *SrcTy, Type *DestTy,
137 const DataLayout &DL) {
138 assert(canReinterpret(SrcTy, DestTy, DL) &&
139 "Cannot reinterpret a non-integral pointer!");
140 assert(Utils::getNumBits(SrcTy, DL) == Utils::getNumBits(DestTy, DL) &&
141 "Expected types of the same size!");
143 if (SrcTy == DestTy)
144 return Chain;
145 Type *Ty = SrcTy;
146 if (Ty->getScalarType()->isPointerTy()) {
147 Ty = getIntTypeFor(Ty, DL);
148 Chain.emplace_back(Instruction::Opcode::PtrToInt, Ty);
149 }
150 bool DestIsPtr = DestTy->getScalarType()->isPointerTy();
151 Type *BitCastTy = DestIsPtr ? getIntTypeFor(DestTy, DL) : DestTy;
152 if (Ty != BitCastTy)
153 Chain.emplace_back(Instruction::Opcode::BitCast, BitCastTy);
154 if (DestIsPtr)
155 Chain.emplace_back(Instruction::Opcode::IntToPtr, DestTy);
156 // ptrtoint, bitcast, and inttoptr, with any step omitted. A vector of
157 // pointers and a scalar pointer of the same width need all three.
158 assert(Chain.size() <= 3 && "Unexpected reinterpret cast chain!");
159 return Chain;
160}
161
163 BasicBlock::iterator WhereIt,
164 Context &Ctx,
165 const DataLayout &DL) {
166 if (!canReinterpret(V->getType(), DestTy, DL))
167 return nullptr;
168 Value *NewV = V;
169 for (auto [Opc, Ty] : getCastChain(V->getType(), DestTy, DL))
170 NewV = CastInst::create(Ty, Opc, NewV, WhereIt, Ctx, "VCast");
171 return NewV;
172}
173
175 const DataLayout &DL) {
176 if (!canReinterpret(C->getType(), DestTy, DL))
177 return nullptr;
178 Constant *NewC = C;
179 for (auto [Opc, Ty] : getCastChain(C->getType(), DestTy, DL)) {
180 switch (Opc) {
181 case Instruction::Opcode::PtrToInt:
182 NewC = ConstantExpr::getPtrToInt(NewC, Ty);
183 break;
184 case Instruction::Opcode::BitCast:
185 NewC = ConstantExpr::getBitCast(NewC, Ty);
186 break;
187 case Instruction::Opcode::IntToPtr:
188 NewC = ConstantExpr::getIntToPtr(NewC, Ty);
189 break;
190 default:
191 llvm_unreachable("Unexpected cast in reinterpret chain!");
192 }
193 }
194 return NewC;
195}
196
197Constant *LoadStoreVec::createConstantVector(BndlRef<Constant *> Constants) {
198 auto *VecTy =
200 auto *LaneTy = VecTy->getScalarType();
201 unsigned LaneBits = Utils::getNumBits(LaneTy, *DL);
202 assert(all_of(Constants,
203 [&](Value *V) {
204 return Utils::getNumBits(V, *DL) % LaneBits == 0;
205 }) &&
206 "Chain contains a constant which cannot be converted or split");
207
208 // Some of the contents of Constants may be vectors, like <i8 1, i8 2>.
209 // Collect each scalar element in ConstantElements.
210 SmallVector<Constant *, 4> ConstantElements;
211 for (Constant *COp : Constants) {
212 if (auto *AggrCOp = dyn_cast<ConstantAggregate>(COp)) {
213 // If the operand is a constant aggregate, then append all its elements.
214 // TODO: Flatten nested aggregates such as {i32, {i32, <2 x i32>}} in a
215 // follow-up.
216 for (Value *Elm : AggrCOp->operands())
217 ConstantElements.push_back(cast<Constant>(Elm));
218 } else if (auto *SeqCOp = dyn_cast<ConstantDataSequential>(COp)) {
219 for (auto ElmIdx : seq<unsigned>(SeqCOp->getNumElements()))
220 ConstantElements.push_back(SeqCOp->getElementAsConstant(ElmIdx));
221 } else if (auto *Zero = dyn_cast<ConstantAggregateZero>(COp)) {
222 auto *ZeroElm = Zero->getSequentialElement();
223 for ([[maybe_unused]] auto Cnt :
224 seq<unsigned>(Zero->getElementCount().getFixedValue()))
225 ConstantElements.push_back(ZeroElm);
226 } else if (isa<ConstantInt>(COp) && isa<VectorType>(COp->getType())) {
227 auto *Elm = ConstantInt::get(*Ctx, cast<ConstantInt>(COp)->getValue());
228 for ([[maybe_unused]] auto Cnt :
229 seq<unsigned>(cast<VectorType>(COp->getType())
230 ->getElementCount()
231 .getFixedValue()))
232 ConstantElements.push_back(Elm);
233 } else if (isa<ConstantFP>(COp) && isa<VectorType>(COp->getType())) {
234 auto *Elm = ConstantFP::get(cast<ConstantFP>(COp)->getValue(), *Ctx);
235 for ([[maybe_unused]] auto Cnt :
236 seq<unsigned>(cast<VectorType>(COp->getType())
237 ->getElementCount()
238 .getFixedValue()))
239 ConstantElements.push_back(Elm);
240 } else if (isa<PoisonValue>(COp) && isa<VectorType>(COp->getType())) {
241 auto *Elm =
242 PoisonValue::get(cast<VectorType>(COp->getType())->getElementType());
243 for ([[maybe_unused]] auto Cnt :
244 seq<unsigned>(cast<VectorType>(COp->getType())
245 ->getElementCount()
246 .getFixedValue()))
247 ConstantElements.push_back(Elm);
248 } else if (isa<VectorType>(COp->getType())) {
249 // TODO: Flatten the remaining vector constants.
250 return nullptr;
251 } else {
252 ConstantElements.push_back(COp);
253 }
254 }
255
256 // The elements in ConstantElements may not be of the same type, so we need to
257 // convert them to LaneTy such that we end up getting a vector
258 // <ConstantElements.size() x LaneTy>. This may involve converting integers to
259 // floats (e.g., float 1.0 to i32 0x3f800000), widening or slicing values if
260 // not at LaneTy bit-width (e.g., i16 0x0101 to i8 0x01, i8 0x01 on
261 // little-endian), or a combination of the two.
262 SmallVector<Constant *, 8> LaneTyConstants;
263 LaneTyConstants.reserve(ConstantElements.size());
264 for (Constant *C : ConstantElements) {
265 unsigned Bits = Utils::getNumBits(C, *DL);
266 if (Bits == LaneBits) {
268 if (Lane == nullptr)
269 return nullptr;
270 LaneTyConstants.push_back(Lane);
271 } else if (Bits > LaneBits) {
272 // C is wider than LaneTy, so slice it into LaneTy-sized pieces. That
273 // needs a known bit pattern. A ConstantExpr (for example, ptrtoint of a
274 // global) or a global's address is only known at link time and cannot
275 // be sliced.
277 return nullptr;
278 APInt Val;
279 if (auto *CI = dyn_cast<ConstantInt>(C))
280 Val = CI->getValue();
281 else if (auto *CFP = dyn_cast<ConstantFP>(C))
282 Val = CFP->getValue().bitcastToAPInt();
283 else
284 Val = APInt::getZero(Bits);
285 unsigned NumSlices = Bits / LaneBits;
286 for (unsigned SliceIdx : seq<unsigned>(NumSlices)) {
287 unsigned EndianAwareSlice =
288 DL->isLittleEndian() ? SliceIdx : NumSlices - 1 - SliceIdx;
289 // extractBits returns an integer. Convert that slice back to LaneTy
290 // without changing its bits, so a float lane stays a float.
291 Constant *SliceCInt = ConstantInt::get(
292 *Ctx, Val.extractBits(LaneBits, EndianAwareSlice * LaneBits));
293 Constant *SliceC =
294 SameSizeReinterpret::reinterpretConstant(SliceCInt, LaneTy, *DL);
295 if (SliceC == nullptr)
296 return nullptr;
297 LaneTyConstants.push_back(SliceC);
298 }
299 } else {
300 llvm_unreachable("Vector element type size was calculated incorrectly");
301 }
302 }
303 return ConstantVector::get(LaneTyConstants);
304}
305
306bool LoadStoreVec::vectorizeStores(BndlRef<Instruction *> Stores, Region &Rgn) {
307 if (!canVectorize(Stores))
308 return false;
309 SmallVector<Value *, 4> Operands;
310 Operands.reserve(Stores.size());
311 for (auto *I : Stores) {
312 auto *Op = cast<StoreInst>(I)->getValueOperand();
313 Operands.push_back(Op);
314 }
315 BasicBlock *BB = Stores[0]->getParent();
316 // TODO: For now we only support load operands.
317 // TODO: For now we don't cross BBs.
318 // TODO: For now don't vectorize if the loads have external uses.
319 bool AllLoads = all_of(Operands, [BB](Value *V) {
320 auto *LI = dyn_cast<LoadInst>(V);
321 if (LI == nullptr)
322 return false;
323 // TODO: For now we don't cross BBs.
324 if (LI->getParent() != BB)
325 return false;
326 if (LI->hasNUsesOrMore(2))
327 return false;
328 return true;
329 });
330 bool AllConstants =
331 all_of(Operands, [](Value *V) { return isa<Constant>(V); });
332 if (!AllLoads && !AllConstants)
333 return false;
334
335 // Vectorizing mixed floats and integers with external uses may not be
336 // profitable on some targets, so save state here.
337 saveIR(Rgn);
338 Value *VecOp = nullptr;
339 SmallVector<Instruction *, 8> Loads;
340 if (AllLoads) {
341 Loads.reserve(Operands.size());
342 for (Value *Op : Operands)
343 Loads.push_back(cast<Instruction>(Op));
344 if (!canVectorize(Loads)) {
345 Ctx->accept();
346 return false;
347 }
348 VecOp = createVectorLoad(Loads);
349 assert(VecOp != nullptr && "Expected vector value!");
350 } else if (AllConstants) {
352 Constants.reserve(Operands.size());
353 for (Value *Op : Operands)
354 Constants.push_back(cast<Constant>(Op));
355 VecOp = createConstantVector(Constants);
356 if (VecOp == nullptr) {
357 Ctx->accept();
358 return false;
359 }
360 }
361
362 // Generate vector store.
363 Value *StPtr = cast<StoreInst>(Stores[0])->getPointerOperand();
364 Align StAlign = VecUtils::getVecAlignment(Stores);
365 auto StWhereIt = std::next(VecUtils::getLowest(Stores)->getIterator());
366 auto *VecS = StoreInst::create(VecOp, StPtr, StAlign, StWhereIt, *Ctx);
367 Utils::propagateMetadata(VecS, Stores);
368
369 DeadInstrMorgue.collectPotentiallyDeadInstrs(Stores);
370 if (AllLoads)
371 DeadInstrMorgue.collectPotentiallyDeadInstrs<Instruction>(Loads);
372 DeadInstrMorgue.tryEraseDeadInstrs();
373
374 return acceptOrRevert();
375}
376
377LoadInst *LoadStoreVec::vectorizeLoads(BndlRef<Instruction *> Loads,
378 Region &Rgn) {
379 auto VecTy = canVectorize(Loads);
380 if (!VecTy)
381 return nullptr;
382
383 // Each load is unpacked from the lanes it occupies in the vector and, for a
384 // chain of mixed types, reinterpreted back as the type of the load.
385 if (!canUnpack(cast<FixedVectorType>(*VecTy),
386 map_range(Loads, [](Instruction *I) { return I->getType(); })))
387 return nullptr;
388
389 saveIR(Rgn);
390
391 auto *VecLoad = createVectorLoad(Loads);
392 assert(VecLoad != nullptr && "Expected vector load");
393 unpackIfNeeded(VecLoad, Loads);
394
395 DeadInstrMorgue.collectPotentiallyDeadInstrs(Loads);
396 DeadInstrMorgue.tryEraseDeadInstrs();
397
398 if (!acceptOrRevert())
399 return nullptr;
400 return VecLoad;
401}
402
403bool LoadStoreVec::runOnRegion(Region &Rgn, const Analyses &RegionAnalyses) {
404 SmallVector<Instruction *, 8> Bndl(Rgn.getAux().begin(), Rgn.getAux().end());
405 if (Bndl.size() < 2)
406 return false;
407 Function &F = *Bndl[0]->getParent()->getParent();
408 DL = &F.getParent()->getDataLayout();
409 Ctx = &F.getContext();
410 A = &RegionAnalyses;
411 InstrMaps IMaps;
412 auto Opc = Bndl[0]->getOpcode();
413 assert(
414 all_of(Bndl, [Opc](Instruction *I) { return I->getOpcode() == Opc; }) &&
415 "Expected a homogeneous seed slice!");
416
417 SchedDirection Dir;
418 switch (Opc) {
419 case Instruction::Opcode::Load:
421 break;
422 case Instruction::Opcode::Store:
424 break;
425 default:
426 llvm_unreachable("Expected Load or Store");
427 }
428
429 LegalityAnalysis L(A->getAA(), A->getScalarEvolution(),
430 F.getParent()->getDataLayout(), A->getTTI(),
431 F.getContext(), IMaps, Dir);
432 Legality = &L;
433
434 // Save state for the top-level roll-back if not Changed (below).
435 Ctx->save();
436
437 bool Changed = false;
438 switch (Opc) {
439 case Instruction::Opcode::Load:
440 Changed = vectorizeLoads(Bndl, Rgn) != nullptr;
441 break;
442 case Instruction::Opcode::Store:
443 Changed = vectorizeStores(Bndl, Rgn);
444 break;
445 default:
446 llvm_unreachable("Expected Load or Store");
447 }
448
449 // The IR may have changed even if Changed == false, because of scheduling.
450 // So to be save revert the state.
451 if (!Changed)
452 Ctx->revert();
453 else
454 Ctx->accept();
455 return Changed;
456}
457
458} // namespace sandboxir
459
460} // namespace llvm
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
static constexpr Value * getValue(Ty &ValueOrUse)
#define DEBUG_PREFIX_LOCAL
unsigned Opc
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
SI Fold Operands
This file contains some templates that are useful if you are working with the STL at all.
#define LLVM_DEBUG(...)
Definition Debug.h:119
#define DEBUG_PREFIX
Definition Debug.h:19
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Definition APInt.h:196
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:169
This is an important base class in LLVM.
Definition Constant.h:44
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
Class to represent fixed width SIMD vectors.
void reserve(size_type N)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Type * getElementType() const
An ArrayRef of Values or Instructions that we can print/dump for debugging.
Definition VecUtils.h:39
static LLVM_ABI Value * create(Type *DestTy, Opcode Op, Value *Operand, InsertPosition Pos, Context &Ctx, const Twine &Name="")
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty)
Definition Constant.cpp:482
static LLVM_ABI Constant * getPtrToInt(Constant *C, Type *Ty)
Definition Constant.cpp:470
static LLVM_ABI Constant * getIntToPtr(Constant *C, Type *Ty)
Definition Constant.cpp:476
static LLVM_ABI Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
Definition Constant.cpp:90
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 Constant * get(ArrayRef< Constant * > V)
Definition Constant.cpp:176
void save()
Convenience function for getTracker().save()
Definition Context.h:252
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Maps the original instructions to the vectorized instrs and the reverse.
Definition InstrMaps.h:49
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Definition Instruction.h:43
static LLVM_ABI IntegerType * get(Context &C, unsigned NumBits)
Performs the legality analysis and returns a LegalityResult object.
Definition Legality.h:322
LLVM_ABI const LegalityResult & canVectorizeLSV(BndlRef< Instruction * > Bndl)
Similar to canVectorize() but specific to LoadStoreVec.
Definition Legality.cpp:286
static LLVM_ABI LoadInst * create(Type *Ty, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx, const Twine &Name="")
bool runOnRegion(Region &Rgn, const Analyses &A) final
\Returns true if it modifies R.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition Constant.cpp:263
Context & getContext() const
Definition Region.h:169
static LLVM_ABI Constant * reinterpretConstant(Constant *C, Type *DestTy, const DataLayout &DL)
Reinterprets constant C as DestTy, e.g., float 1.0 to i32 0x3f800000, or a null pointer to i64 0.
static LLVM_ABI Value * reinterpretValue(Value *V, Type *DestTy, BasicBlock::iterator WhereIt, Context &Ctx, const DataLayout &DL)
Reinterprets V as DestTy, which must have the same size in DL, inserting casts before WhereIt.
static LLVM_ABI bool canReinterpret(Type *SrcTy, Type *DestTy, const DataLayout &DL)
static LLVM_ABI StoreInst * create(Value *V, Value *Ptr, MaybeAlign Align, InsertPosition Pos, bool IsVolatile, Context &Ctx)
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition Type.h:48
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition Type.h:301
LLVM_ABI Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isPointerTy() const
True if this is an instance of PointerType.
Definition Type.h:206
static void propagateMetadata(Instruction *I, const ValueRangeT &VL)
Definition Utils.h:148
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
Definition Utils.h:68
A SandboxIR Value has users. This is the base class.
Definition Value.h:72
static Instruction * getLowest(ArrayRef< Instruction * > Instrs)
\Returns the instruction in Instrs that is lowest in the BB.
Definition VecUtils.h:240
static unsigned getNumLanes(Type *Ty)
\Returns the number of vector lanes of Ty or 1 if not a vector.
Definition VecUtils.h:134
static Value * unpack(Value *FromVec, Type *ExtrTy, unsigned Lane, BasicBlock::iterator WhereIt)
Emits the necessary instruction sequence to extract element of type ExtrTy at Lane from FromVec.
Definition VecUtils.h:418
static LLVM_DUMP_METHOD void dump(ArrayRef< Value * > Bndl)
Helper dump function for debugging.
Definition VecUtils.cpp:166
static Align getVecAlignment(AlignRangeT AlignRange, TypeRangeT TypeRange)
Given the alignments of the instructions before vectorization, this returns the alignment of the vect...
Definition VecUtils.h:547
static Type * getCombinedVectorTypeFor(BndlRef< T * > Bndl, const DataLayout &DL)
\Returns the combined vector type for Bndl, even when the element types differ.
Definition VecUtils.h:205
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
BndlRef(const T &OneElt) -> BndlRef< T >
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
Definition BasicBlock.h:75
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
static bool isNonIntegralPtr(Type *Ty, const DataLayout &DL)
static Type * getWidenedType(Type *ElemTy, unsigned N)
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
Definition STLExtras.h:366
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
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
DWARFExpression::Operation Op
const VectorizeOptions & getVectorizeOptions(const LLVMContext &C)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Definition Sequence.h:341
#define N