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
78LoadInst *LoadStoreVec::createVectorLoad(BndlRef<Instruction *> Loads) {
80 Value *LdPtr = cast<LoadInst>(Loads[0])->getPointerOperand();
81 Align LdAlign = VecUtils::getVecAlignment(Loads);
82 auto LdWhereIt = std::next(VecUtils::getLowest(Loads)->getIterator());
83 auto *VecL =
84 LoadInst::create(Ty, LdPtr, LdAlign, LdWhereIt, *Ctx, "VecIinitL");
85 Utils::propagateMetadata(VecL, Loads);
86 return VecL;
87}
88
90 const DataLayout &DL) {
91 return !isNonIntegralPtr(SrcTy, DL) && !isNonIntegralPtr(DestTy, DL);
92}
93
94Type *SameSizeReinterpret::getIntTypeFor(Type *Ty, const DataLayout &DL) {
95 Context &Ctx = Ty->getContext();
96 if (auto *VecTy = dyn_cast<FixedVectorType>(Ty)) {
97 auto *ElmIntTy =
98 IntegerType::get(Ctx, Utils::getNumBits(VecTy->getElementType(), DL));
99 return FixedVectorType::get(ElmIntTy, VecTy->getNumElements());
100 }
101 return IntegerType::get(Ctx, Utils::getNumBits(Ty, DL));
102}
103
105SameSizeReinterpret::getCastChain(Type *SrcTy, Type *DestTy,
106 const DataLayout &DL) {
107 assert(canReinterpret(SrcTy, DestTy, DL) &&
108 "Cannot reinterpret a non-integral pointer!");
109 assert(Utils::getNumBits(SrcTy, DL) == Utils::getNumBits(DestTy, DL) &&
110 "Expected types of the same size!");
112 if (SrcTy == DestTy)
113 return Chain;
114 Type *Ty = SrcTy;
115 if (Ty->getScalarType()->isPointerTy()) {
116 Ty = getIntTypeFor(Ty, DL);
117 Chain.emplace_back(Instruction::Opcode::PtrToInt, Ty);
118 }
119 bool DestIsPtr = DestTy->getScalarType()->isPointerTy();
120 Type *BitCastTy = DestIsPtr ? getIntTypeFor(DestTy, DL) : DestTy;
121 if (Ty != BitCastTy)
122 Chain.emplace_back(Instruction::Opcode::BitCast, BitCastTy);
123 if (DestIsPtr)
124 Chain.emplace_back(Instruction::Opcode::IntToPtr, DestTy);
125 // ptrtoint, bitcast, and inttoptr, with any step omitted. A vector of
126 // pointers and a scalar pointer of the same width need all three.
127 assert(Chain.size() <= 3 && "Unexpected reinterpret cast chain!");
128 return Chain;
129}
130
132 BasicBlock::iterator WhereIt,
133 Context &Ctx,
134 const DataLayout &DL) {
135 if (!canReinterpret(V->getType(), DestTy, DL))
136 return nullptr;
137 Value *NewV = V;
138 for (auto [Opc, Ty] : getCastChain(V->getType(), DestTy, DL))
139 NewV = CastInst::create(Ty, Opc, NewV, WhereIt, Ctx, "VCast");
140 return NewV;
141}
142
144 const DataLayout &DL) {
145 if (!canReinterpret(C->getType(), DestTy, DL))
146 return nullptr;
147 Constant *NewC = C;
148 for (auto [Opc, Ty] : getCastChain(C->getType(), DestTy, DL)) {
149 switch (Opc) {
150 case Instruction::Opcode::PtrToInt:
151 NewC = ConstantExpr::getPtrToInt(NewC, Ty);
152 break;
153 case Instruction::Opcode::BitCast:
154 NewC = ConstantExpr::getBitCast(NewC, Ty);
155 break;
156 case Instruction::Opcode::IntToPtr:
157 NewC = ConstantExpr::getIntToPtr(NewC, Ty);
158 break;
159 default:
160 llvm_unreachable("Unexpected cast in reinterpret chain!");
161 }
162 }
163 return NewC;
164}
165
166Constant *LoadStoreVec::createConstantVector(BndlRef<Constant *> Constants) {
167 auto *VecTy =
169 auto *LaneTy = VecTy->getScalarType();
170 unsigned LaneBits = Utils::getNumBits(LaneTy, *DL);
171 assert(all_of(Constants,
172 [&](Value *V) {
173 return Utils::getNumBits(V, *DL) % LaneBits == 0;
174 }) &&
175 "Chain contains a constant which cannot be converted or split");
176
177 // Some of the contents of Constants may be vectors, like <i8 1, i8 2>.
178 // Collect each scalar element in ConstantElements.
179 SmallVector<Constant *, 4> ConstantElements;
180 for (Constant *COp : Constants) {
181 if (auto *AggrCOp = dyn_cast<ConstantAggregate>(COp)) {
182 // If the operand is a constant aggregate, then append all its elements.
183 // TODO: Flatten nested aggregates such as {i32, {i32, <2 x i32>}} in a
184 // follow-up.
185 for (Value *Elm : AggrCOp->operands())
186 ConstantElements.push_back(cast<Constant>(Elm));
187 } else if (auto *SeqCOp = dyn_cast<ConstantDataSequential>(COp)) {
188 for (auto ElmIdx : seq<unsigned>(SeqCOp->getNumElements()))
189 ConstantElements.push_back(SeqCOp->getElementAsConstant(ElmIdx));
190 } else if (auto *Zero = dyn_cast<ConstantAggregateZero>(COp)) {
191 auto *ZeroElm = Zero->getSequentialElement();
192 for ([[maybe_unused]] auto Cnt :
193 seq<unsigned>(Zero->getElementCount().getFixedValue()))
194 ConstantElements.push_back(ZeroElm);
195 } else if (isa<ConstantInt>(COp) && isa<VectorType>(COp->getType())) {
196 auto *Elm = ConstantInt::get(*Ctx, cast<ConstantInt>(COp)->getValue());
197 for ([[maybe_unused]] auto Cnt :
198 seq<unsigned>(cast<VectorType>(COp->getType())
199 ->getElementCount()
200 .getFixedValue()))
201 ConstantElements.push_back(Elm);
202 } else if (isa<ConstantFP>(COp) && isa<VectorType>(COp->getType())) {
203 auto *Elm = ConstantFP::get(cast<ConstantFP>(COp)->getValue(), *Ctx);
204 for ([[maybe_unused]] auto Cnt :
205 seq<unsigned>(cast<VectorType>(COp->getType())
206 ->getElementCount()
207 .getFixedValue()))
208 ConstantElements.push_back(Elm);
209 } else if (isa<PoisonValue>(COp) && isa<VectorType>(COp->getType())) {
210 auto *Elm =
211 PoisonValue::get(cast<VectorType>(COp->getType())->getElementType());
212 for ([[maybe_unused]] auto Cnt :
213 seq<unsigned>(cast<VectorType>(COp->getType())
214 ->getElementCount()
215 .getFixedValue()))
216 ConstantElements.push_back(Elm);
217 } else if (isa<VectorType>(COp->getType())) {
218 // TODO: Flatten the remaining vector constants.
219 return nullptr;
220 } else {
221 ConstantElements.push_back(COp);
222 }
223 }
224
225 // The elements in ConstantElements may not be of the same type, so we need to
226 // convert them to LaneTy such that we end up getting a vector
227 // <ConstantElements.size() x LaneTy>. This may involve converting integers to
228 // floats (e.g., float 1.0 to i32 0x3f800000), widening or slicing values if
229 // not at LaneTy bit-width (e.g., i16 0x0101 to i8 0x01, i8 0x01 on
230 // little-endian), or a combination of the two.
231 SmallVector<Constant *, 8> LaneTyConstants;
232 LaneTyConstants.reserve(ConstantElements.size());
233 for (Constant *C : ConstantElements) {
234 unsigned Bits = Utils::getNumBits(C, *DL);
235 if (Bits == LaneBits) {
237 if (Lane == nullptr)
238 return nullptr;
239 LaneTyConstants.push_back(Lane);
240 } else if (Bits > LaneBits) {
241 // C is wider than LaneTy, so slice it into LaneTy-sized pieces. That
242 // needs a known bit pattern. A ConstantExpr (for example, ptrtoint of a
243 // global) or a global's address is only known at link time and cannot
244 // be sliced.
246 return nullptr;
247 APInt Val;
248 if (auto *CI = dyn_cast<ConstantInt>(C))
249 Val = CI->getValue();
250 else if (auto *CFP = dyn_cast<ConstantFP>(C))
251 Val = CFP->getValue().bitcastToAPInt();
252 else
253 Val = APInt::getZero(Bits);
254 unsigned NumSlices = Bits / LaneBits;
255 for (unsigned SliceIdx : seq<unsigned>(NumSlices)) {
256 unsigned EndianAwareSlice =
257 DL->isLittleEndian() ? SliceIdx : NumSlices - 1 - SliceIdx;
258 // extractBits returns an integer. Convert that slice back to LaneTy
259 // without changing its bits, so a float lane stays a float.
260 Constant *SliceCInt = ConstantInt::get(
261 *Ctx, Val.extractBits(LaneBits, EndianAwareSlice * LaneBits));
262 Constant *SliceC =
263 SameSizeReinterpret::reinterpretConstant(SliceCInt, LaneTy, *DL);
264 if (SliceC == nullptr)
265 return nullptr;
266 LaneTyConstants.push_back(SliceC);
267 }
268 } else {
269 llvm_unreachable("Vector element type size was calculated incorrectly");
270 }
271 }
272 return ConstantVector::get(LaneTyConstants);
273}
274
275bool LoadStoreVec::vectorizeStores(BndlRef<Instruction *> Stores, Region &Rgn) {
276 if (!canVectorize(Stores))
277 return false;
278 SmallVector<Value *, 4> Operands;
279 Operands.reserve(Stores.size());
280 for (auto *I : Stores) {
281 auto *Op = cast<StoreInst>(I)->getValueOperand();
282 Operands.push_back(Op);
283 }
284 BasicBlock *BB = Stores[0]->getParent();
285 // TODO: For now we only support load operands.
286 // TODO: For now we don't cross BBs.
287 // TODO: For now don't vectorize if the loads have external uses.
288 bool AllLoads = all_of(Operands, [BB](Value *V) {
289 auto *LI = dyn_cast<LoadInst>(V);
290 if (LI == nullptr)
291 return false;
292 // TODO: For now we don't cross BBs.
293 if (LI->getParent() != BB)
294 return false;
295 if (LI->hasNUsesOrMore(2))
296 return false;
297 return true;
298 });
299 bool AllConstants =
300 all_of(Operands, [](Value *V) { return isa<Constant>(V); });
301 if (!AllLoads && !AllConstants)
302 return false;
303
304 // Vectorizing mixed floats and integers with external uses may not be
305 // profitable on some targets, so save state here.
306 saveIR(Rgn);
307 Value *VecOp = nullptr;
308 SmallVector<Instruction *, 8> Loads;
309 if (AllLoads) {
310 Loads.reserve(Operands.size());
311 for (Value *Op : Operands)
312 Loads.push_back(cast<Instruction>(Op));
313 if (!canVectorize(Loads)) {
314 Ctx->accept();
315 return false;
316 }
317 VecOp = createVectorLoad(Loads);
318 assert(VecOp != nullptr && "Expected vector value!");
319 } else if (AllConstants) {
321 Constants.reserve(Operands.size());
322 for (Value *Op : Operands)
323 Constants.push_back(cast<Constant>(Op));
324 VecOp = createConstantVector(Constants);
325 if (VecOp == nullptr) {
326 Ctx->accept();
327 return false;
328 }
329 }
330
331 // Generate vector store.
332 Value *StPtr = cast<StoreInst>(Stores[0])->getPointerOperand();
333 Align StAlign = VecUtils::getVecAlignment(Stores);
334 auto StWhereIt = std::next(VecUtils::getLowest(Stores)->getIterator());
335 auto *VecS = StoreInst::create(VecOp, StPtr, StAlign, StWhereIt, *Ctx);
336 Utils::propagateMetadata(VecS, Stores);
337
338 DeadInstrMorgue.collectPotentiallyDeadInstrs(Stores);
339 if (AllLoads)
340 DeadInstrMorgue.collectPotentiallyDeadInstrs<Instruction>(Loads);
341 DeadInstrMorgue.tryEraseDeadInstrs();
342
343 return acceptOrRevert();
344}
345
346LoadInst *LoadStoreVec::vectorizeLoads(BndlRef<Instruction *> Loads,
347 Region &Rgn) {
348 auto VecTy = canVectorize(Loads);
349 if (!VecTy)
350 return nullptr;
351
352 // Each load is unpacked from the lanes it occupies in the vector and, for a
353 // chain of mixed types, reinterpreted back as the type of the load.
354 Type *VecElemTy = cast<FixedVectorType>(*VecTy)->getElementType();
355 unsigned ElemBits = Utils::getNumBits(VecElemTy, *DL);
356 if (any_of(Loads, [this, VecElemTy, ElemBits](Instruction *I) {
357 unsigned NumElems = Utils::getNumBits(I) / ElemBits;
359 getWidenedType(VecElemTy, NumElems), I->getType(), *DL);
360 }))
361 return nullptr;
362
363 saveIR(Rgn);
364
365 auto *VecLoad = createVectorLoad(Loads);
366 assert(VecLoad != nullptr && "Expected vector load");
367
368 // Lanes are counted in units of VecElemTy, so a load wider than VecElemTy
369 // spans several lanes.
370 BasicBlock::iterator WhereIt = std::next(VecLoad->getIterator());
371 unsigned Lane = 0;
372 for (Instruction *I : Loads) {
373 unsigned NumElems =
374 Utils::getNumBits(I) / Utils::getNumBits(VecElemTy, *DL);
375 Type *UnpackTy = getWidenedType(VecElemTy, NumElems);
376 unsigned NumLanes = VecUtils::getNumLanes(UnpackTy);
377 if (!I->hasNUses(0)) {
378 Value *Unpacked = VecUtils::unpack(VecLoad, UnpackTy, Lane, WhereIt);
379 Unpacked = SameSizeReinterpret::reinterpretValue(Unpacked, I->getType(),
380 WhereIt, *Ctx, *DL);
381 I->replaceAllUsesWith(Unpacked);
382 }
383 Lane += NumLanes;
384 }
385
386 DeadInstrMorgue.collectPotentiallyDeadInstrs(Loads);
387 DeadInstrMorgue.tryEraseDeadInstrs();
388
389 if (!acceptOrRevert())
390 return nullptr;
391 return VecLoad;
392}
393
394bool LoadStoreVec::runOnRegion(Region &Rgn, const Analyses &RegionAnalyses) {
395 SmallVector<Instruction *, 8> Bndl(Rgn.getAux().begin(), Rgn.getAux().end());
396 if (Bndl.size() < 2)
397 return false;
398 Function &F = *Bndl[0]->getParent()->getParent();
399 DL = &F.getParent()->getDataLayout();
400 Ctx = &F.getContext();
401 A = &RegionAnalyses;
402 InstrMaps IMaps;
403 auto Opc = Bndl[0]->getOpcode();
404 assert(
405 all_of(Bndl, [Opc](Instruction *I) { return I->getOpcode() == Opc; }) &&
406 "Expected a homogeneous seed slice!");
407
408 SchedDirection Dir;
409 switch (Opc) {
410 case Instruction::Opcode::Load:
412 break;
413 case Instruction::Opcode::Store:
415 break;
416 default:
417 llvm_unreachable("Expected Load or Store");
418 }
419
420 LegalityAnalysis L(A->getAA(), A->getScalarEvolution(),
421 F.getParent()->getDataLayout(), A->getTTI(),
422 F.getContext(), IMaps, Dir);
423 Legality = &L;
424
425 // Save state for the top-level roll-back if not Changed (below).
426 Ctx->save();
427
428 bool Changed = false;
429 switch (Opc) {
430 case Instruction::Opcode::Load:
431 Changed = vectorizeLoads(Bndl, Rgn) != nullptr;
432 break;
433 case Instruction::Opcode::Store:
434 Changed = vectorizeStores(Bndl, Rgn);
435 break;
436 default:
437 llvm_unreachable("Expected Load or Store");
438 }
439
440 // The IR may have changed even if Changed == false, because of scheduling.
441 // So to be save revert the state.
442 if (!Changed)
443 Ctx->revert();
444 else
445 Ctx->accept();
446 return Changed;
447}
448
449} // namespace sandboxir
450
451} // 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
#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:170
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:64
An instruction for reading from memory.
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
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
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1762
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
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39