LLVM 24.0.0git
VecUtils.h
Go to the documentation of this file.
1//===- VecUtils.h -----------------------------------------------*- C++ -*-===//
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// Collector for SandboxVectorizer related convenience functions that don't
10// belong in other classes.
11
12#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_VECUTILS_H
13#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_VECUTILS_H
14
16#include "llvm/IR/DataLayout.h"
17#include "llvm/SandboxIR/Type.h"
20#include <iterator>
21
22namespace llvm {
23/// Traits for DenseMap.
24template <> struct DenseMapInfo<SmallVector<sandboxir::Value *>> {
25 static unsigned getHashValue(const SmallVector<sandboxir::Value *> &Vec) {
26 return hash_combine_range(Vec);
27 }
30 return Vec1 == Vec2;
31 }
32};
33
34namespace sandboxir {
35
36class InstrMaps;
37
39
40class VecUtils {
41public:
42 /// \Returns the number of elements in \p Ty. That is the number of lanes if a
43 /// fixed vector or 1 if scalar. ScalableVectors have unknown size and
44 /// therefore are unsupported.
45 static int getNumElements(Type *Ty) {
47 return Ty->isVectorTy() ? cast<FixedVectorType>(Ty)->getNumElements() : 1;
48 }
49 /// Returns \p Ty if scalar or its element type if vector.
50 static Type *getElementType(Type *Ty) {
51 return Ty->isVectorTy() ? cast<FixedVectorType>(Ty)->getElementType() : Ty;
52 }
53
54 /// \Returns true if \p I1 and \p I2 are load/stores accessing consecutive
55 /// memory addresses.
56 template <typename LoadOrStoreT>
57 static bool areConsecutive(LoadOrStoreT *I1, LoadOrStoreT *I2,
58 ScalarEvolution &SE, const DataLayout &DL) {
59 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
60 std::is_same<LoadOrStoreT, StoreInst>::value,
61 "Expected Load or Store!");
62 auto Diff = Utils::getPointerDiffInBytes(I1, I2, SE);
63 if (!Diff)
64 return false;
65 int ElmBytes = Utils::getNumBits(I1) / 8;
66 return *Diff == ElmBytes;
67 }
68
69 template <typename LoadOrStoreT, typename ValT>
71 const DataLayout &DL) {
72 static_assert(std::is_same<LoadOrStoreT, LoadInst>::value ||
73 std::is_same<LoadOrStoreT, StoreInst>::value,
74 "Expected Load or Store!");
75 assert(isa<LoadOrStoreT>(Bndl[0]) && "Expected Load or Store!");
76 auto *LastLS = cast<LoadOrStoreT>(Bndl[0]);
77 for (Value *V : drop_begin(Bndl)) {
79 "Unimplemented: we only support StoreInst!");
80 auto *LS = cast<LoadOrStoreT>(V);
81 if (!VecUtils::areConsecutive(LastLS, LS, SE, DL))
82 return false;
83 LastLS = LS;
84 }
85 return true;
86 }
87
88 /// \Returns the number of vector lanes of \p Ty or 1 if not a vector.
89 /// NOTE: It asserts that \p Ty is a fixed vector type.
90 static unsigned getNumLanes(Type *Ty) {
91 assert(!isa<ScalableVectorType>(Ty) && "Expect scalar or fixed vector");
92 if (auto *FixedVecTy = dyn_cast<FixedVectorType>(Ty))
93 return FixedVecTy->getNumElements();
94 return 1u;
95 }
96
97 /// \Returns the expected vector lanes of \p V or 1 if not a vector.
98 /// NOTE: It asserts that \p V is a fixed vector.
99 static unsigned getNumLanes(Value *V) {
101 }
102
103 /// \Returns the total number of lanes across all values in \p Bndl.
104 static unsigned getNumLanes(ArrayRef<Value *> Bndl) {
105 unsigned Lanes = 0;
106 for (Value *V : Bndl)
107 Lanes += getNumLanes(V);
108 return Lanes;
109 }
110
111 /// \Returns <NumElts x ElemTy>.
112 /// It works for both scalar and vector \p ElemTy.
113 static Type *getWideType(Type *ElemTy, unsigned NumElts) {
114 if (ElemTy->isVectorTy()) {
115 auto *VecTy = cast<FixedVectorType>(ElemTy);
116 ElemTy = VecTy->getElementType();
117 NumElts = VecTy->getNumElements() * NumElts;
118 }
119 return FixedVectorType::get(ElemTy, NumElts);
120 }
121 /// \Returns the combined vector type for \p Bndl, even when the element types
122 /// differ. For example: i8,i8,i16 will return <4 x i8>. \Returns null if
123 /// types are of mixed float/integer types.
125 const DataLayout &DL) {
126 assert(!Bndl.empty() && "Expected non-empty Bndl!");
127 unsigned TotalBits = 0;
128 unsigned MinElmBits = std::numeric_limits<unsigned>::max();
129 Type *MinElmTy = nullptr;
130 for (auto [Idx, V] : enumerate(Bndl)) {
132
133 unsigned ElmBits = Utils::getNumBits(ElmTy, DL);
134 TotalBits += ElmBits * VecUtils::getNumLanes(V);
135 if (ElmBits < MinElmBits) {
136 MinElmBits = ElmBits;
137 MinElmTy = ElmTy;
138 }
139 }
140 unsigned NumElms = TotalBits / MinElmBits;
141 return FixedVectorType::get(MinElmTy, NumElms);
142 }
143 /// \Returns the instruction in \p Instrs that is lowest in the BB. Expects
144 /// that all instructions are in the same BB.
146 Instruction *LowestI = Instrs.front();
147 for (auto *I : drop_begin(Instrs)) {
148 if (LowestI->comesBefore(I))
149 LowestI = I;
150 }
151 return LowestI;
152 }
153 /// \Returns the instruction in \p Instrs that is highest in the BB. Expects
154 /// that all instructions are in the same BB.
156 Instruction *HighestI = Instrs.front();
157 for (auto *I : drop_begin(Instrs)) {
158 if (I->comesBefore(HighestI))
159 HighestI = I;
160 }
161 return HighestI;
162 }
163 /// \Returns the lowest instruction in \p Vals, or nullptr if no instructions
164 /// are found. Skips instructions not in \p BB.
166 // Find the first Instruction in Vals that is also in `BB`.
167 auto It = find_if(Vals, [BB](Value *V) {
168 return isa<Instruction>(V) && cast<Instruction>(V)->getParent() == BB;
169 });
170 // If we couldn't find an instruction return nullptr.
171 if (It == Vals.end())
172 return nullptr;
173 Instruction *FirstI = cast<Instruction>(*It);
174 // Now look for the lowest instruction in Vals starting from one position
175 // after FirstI.
176 Instruction *LowestI = FirstI;
177 for (auto *V : make_range(std::next(It), Vals.end())) {
178 auto *I = dyn_cast<Instruction>(V);
179 // Skip non-instructions.
180 if (I == nullptr)
181 continue;
182 // Skips instructions not in \p BB.
183 if (I->getParent() != BB)
184 continue;
185 // If `LowestI` comes before `I` then `I` is the new lowest.
186 if (LowestI->comesBefore(I))
187 LowestI = I;
188 }
189 return LowestI;
190 }
191
192 /// If \p I is not a PHI it returns it. Else it walks down the instruction
193 /// chain looking for the last PHI and returns it. \Returns nullptr if \p I is
194 /// nullptr.
196 Instruction *LastI = I;
197 while (I != nullptr && isa<PHINode>(I)) {
198 LastI = I;
199 I = I->getNextNode();
200 }
201 return LastI;
202 }
203
204 /// \Returns the BB iterator after the lowest instruction in \p Vals
205 /// (skipping instructions not in \p BB), or the top of BB if no
206 /// instruction found in \p Vals.
208 BasicBlock *BB) {
209 auto *BotI = getLastPHIOrSelf(getLowest(Vals, BB));
210 if (BotI == nullptr)
211 // We are using BB->begin() (or after PHIs) as the fallback insert point.
212 return BB->empty()
213 ? BB->begin()
214 : std::next(getLastPHIOrSelf(&*BB->begin())->getIterator());
215 return std::next(BotI->getIterator());
216 }
217
218 /// If all values in \p Bndl are of the same scalar type then return it,
219 /// otherwise return nullptr.
221 Value *V0 = Bndl[0];
222 Type *Ty0 = Utils::getExpectedType(V0);
223 Type *ScalarTy = VecUtils::getElementType(Ty0);
224 for (auto *V : drop_begin(Bndl)) {
226 Type *NScalarTy = VecUtils::getElementType(NTy);
227 if (NScalarTy != ScalarTy)
228 return nullptr;
229 }
230 return ScalarTy;
231 }
232
233 /// Similar to tryGetCommonScalarType() but will assert that there is a common
234 /// type. So this is faster in release builds as it won't iterate through the
235 /// values.
237 Value *V0 = Bndl[0];
238 Type *Ty0 = Utils::getExpectedType(V0);
239 Type *ScalarTy = VecUtils::getElementType(Ty0);
240 assert(tryGetCommonScalarType(Bndl) && "Expected common scalar type!");
241 return ScalarTy;
242 }
243 /// \Returns the first integer power of 2 that is <= Num.
244 LLVM_ABI static unsigned getFloorPowerOf2(unsigned Num);
245
246 /// For each user of lane 0 in \p Bndl, try to form a bundle of matching
247 /// users for all lanes. Returns all complete user bundles found.
248 /// \p Claimed contains instructions that have already been claimed by a
249 /// bundle.
253
254 /// Helper struct for `matchPack()`. Describes the instructions and operands
255 /// of a pack pattern.
256 struct PackPattern {
257 /// The insertelement instructions that form the pack pattern in bottom-up
258 /// order, i.e., the first instruction in `Instrs` is the bottom-most
259 /// InsertElement instruction of the pack pattern.
260 /// For example in this simple pack pattern:
261 /// %Pack0 = insertelement <2 x i8> poison, i8 %v0, i64 0
262 /// %Pack1 = insertelement <2 x i8> %Pack0, i8 %v1, i64 1
263 /// this is [ %Pack1, %Pack0 ].
265 /// The "external" operands of the pack pattern, i.e., the values that get
266 /// packed into a vector, skipping the ones in `Instrs`. The operands are in
267 /// bottom-up order, starting from the operands of the bottom-most insert.
268 /// So in our example this would be [ %v1, %v0 ].
270 };
271
272 /// If \p I is the last instruction of a pack pattern (i.e., an InsertElement
273 /// into a vector), then this function returns the instructions in the pack
274 /// and the operands in the pack, else returns nullopt.
275 /// Here is an example of a matched pattern:
276 /// %PackA0 = insertelement <2 x i8> poison, i8 %v0, i64 0
277 /// %PackA1 = insertelement <2 x i8> %PackA0, i8 %v1, i64 1
278 /// TODO: this currently detects only simple canonicalized patterns.
279 static std::optional<PackPattern> matchPack(Instruction *I) {
280 // TODO: Support vector pack patterns.
281 // TODO: Support out-of-order inserts.
282
283 // Early return if `I` is not an Insert.
285 return std::nullopt;
286 auto *BB0 = I->getParent();
287 // The pack contains as many instrs as the lanes of the bottom-most Insert
288 unsigned ExpectedNumInserts = VecUtils::getNumLanes(I);
289 assert(ExpectedNumInserts >= 2 && "Expected at least 2 inserts!");
291 Pack.Operands.resize(ExpectedNumInserts);
292 // Collect the inserts by walking up the use-def chain.
293 Instruction *InsertI = I;
294 for (auto ExpectedLane : reverse(seq<unsigned>(ExpectedNumInserts))) {
295 if (InsertI == nullptr)
296 return std::nullopt;
297 if (InsertI->getParent() != BB0)
298 return std::nullopt;
299 // Check the lane.
300 auto *LaneC = dyn_cast<ConstantInt>(InsertI->getOperand(2));
301 if (LaneC == nullptr || LaneC->getSExtValue() != ExpectedLane)
302 return std::nullopt;
303 Pack.Instrs.push_back(InsertI);
304 Pack.Operands[ExpectedLane] = InsertI->getOperand(1);
305
306 Value *Op = InsertI->getOperand(0);
307 if (ExpectedLane == 0) {
308 // Check the topmost insert. The operand should be a Poison.
309 if (!isa<PoisonValue>(Op))
310 return std::nullopt;
311 } else {
313 }
314 }
315 return Pack;
316 }
317
318 /// Emits the necessary instruction sequence to extract element of type \p
319 /// ExtrTy at \p Lane from \p FromVec. Emits instructions before \p WhereIt.
320 /// Returns the extracted value.
321 /// Note: This handles both vectors and scalars. In the vector case it
322 /// extracts an N-wide element (with N dictated by \p ExtrTy).
323 static Value *unpack(Value *FromVec, Type *ExtrTy, unsigned Lane,
324 BasicBlock::iterator WhereIt) {
325 assert(isa<FixedVectorType>(FromVec->getType()) && "Expected vector!");
326 auto &Ctx = FromVec->getContext();
327 if (!ExtrTy->isVectorTy()) {
328 // For scalar elements we emit a single ExtractElementInst.
329 assert(Lane <
330 cast<FixedVectorType>(FromVec->getType())->getNumElements() &&
331 "Out of bounds!");
332 assert(ExtrTy ==
333 cast<FixedVectorType>(FromVec->getType())->getElementType() &&
334 "Expected same element type!");
335 Constant *ExtractLaneC =
337 // Note: This may be folded into a Constant if FromVec is a Constant.
338 return ExtractElementInst::create(FromVec, ExtractLaneC, WhereIt, Ctx,
339 "Unpack");
340 }
341 // For vector elements we emit a shuffle.
342 // For example, extracting lanes 2 and 3 of a <4 x i32> vector %vec:
343 // shufflevector <4 x i32> %vec, <4 x i32> poison, <2 x i32> <i32 2, i32 3>
344 auto *VecTy = cast<FixedVectorType>(FromVec->getType());
345 auto *ExtrVecTy = cast<FixedVectorType>(ExtrTy);
346 assert(ExtrVecTy->getElementType() == VecTy->getElementType() &&
347 "Expected same element type!");
349 for (unsigned Idx = 0, E = ExtrVecTy->getNumElements(); Idx != E; ++Idx) {
350 int MaskLane = Lane + Idx;
351 assert((unsigned)MaskLane <
352 cast<FixedVectorType>(FromVec->getType())->getNumElements() &&
353 "Out of bounds!");
354 Mask.push_back(MaskLane);
355 }
356 return ShuffleVectorInst::create(FromVec, PoisonValue::get(VecTy), Mask,
357 WhereIt, Ctx, "Unpack");
358 }
359
360 /// Iterate over all lanes and Value pairs.
361 // For example, given a range: {i32 %v0, <2 x i32> %v1, i32 %v2} we get:
362 // Lane Elm
363 // 0 %v0
364 // 1 %v1
365 // 3 %v2
366 template <typename RangeIteratorT> class LaneValueEnumerator {
367 /// Points to current element.
368 RangeIteratorT It;
369 RangeIteratorT ItE;
370 /// Accumulator of lanes.
371 unsigned Lane;
372
373 public:
374 // Note that We can start counting from a non-zero BeginLane, though the
375 // user must make sure it corresponds to the correct lane matching Begin.
376 LaneValueEnumerator(RangeIteratorT Begin, RangeIteratorT End,
377 unsigned BeginLane)
378 : It(Begin), ItE(End), Lane(BeginLane) {}
379 using iterator_catecotry = std::input_iterator_tag;
380 // NOTE: dereference returns by value instead of by reference.
381 using value_type = std::pair<unsigned, Value *>;
382 using difference_type = std::ptrdiff_t;
383 using pointer = std::pair<unsigned, Value *> *;
384 using reference = std::pair<unsigned, Value *> &;
386 assert(It != ItE && "Already at end!");
387 auto *Ty = Utils::getExpectedType(*It);
388 if (auto *VecTy = dyn_cast<FixedVectorType>(Ty)) {
389 Lane += VecTy->getNumElements();
390 } else {
391 assert(!isa<VectorType>(Ty) && "Expected scalar type!");
392 Lane += 1;
393 }
394 ++It;
395 return *this;
396 }
397 value_type operator*() const { return {Lane, *It}; }
399 return It == Other.It;
400 }
402 return !(*this == Other);
403 }
404 };
405
406 /// Helper for creating LaneValueEnumerator ranges. Can be used in for loops
407 /// like: `for (auto [Lane, V] : enumerateLanes(Range))`
408 template <typename ValueContainerT>
409 static auto enumerateLanes(const ValueContainerT &Range) {
410 auto Begin = LaneValueEnumerator<decltype(Range.begin())>(Range.begin(),
411 Range.end(), 0);
412 auto End = LaneValueEnumerator<decltype(Range.begin())>(Range.end(),
413 Range.end(), 0);
414 return make_range(Begin, End);
415 }
416
417#ifndef NDEBUG
418 /// Helper dump function for debugging.
419 LLVM_DUMP_METHOD static void dump(ArrayRef<Value *> Bndl);
421#endif // NDEBUG
422};
423
424} // namespace sandboxir
425
426} // namespace llvm
427
428#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_VECUTILS_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:678
#define I(x, y, z)
Definition MD5.cpp:57
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
const T & front() const
Get the first element.
Definition ArrayRef.h:144
iterator end() const
Definition ArrayRef.h:130
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
iterator begin()
Instruction iterator methods.
Definition BasicBlock.h:446
bool empty() const
Definition BasicBlock.h:468
InstListType::iterator iterator
Instruction iterators...
Definition BasicBlock.h:170
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
The main scalar evolution driver.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
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 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 FixedVectorType * get(Type *ElementType, unsigned NumElts)
Maps the original instructions to the vectorized instrs and the reverse.
Definition InstrMaps.h:50
A sandboxir::User with operands, opcode and linked with previous/next instructions in an instruction ...
Definition Instruction.h:43
LLVM_ABI BBIterator getIterator() const
\Returns a BasicBlock::iterator for this Instruction.
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
LLVM_ABI BasicBlock * getParent() const
\Returns the BasicBlock containing this Instruction, or null if it is detached.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Definition Constant.cpp:263
static LLVM_ABI Value * create(Value *V1, Value *V2, Value *Mask, InsertPosition Pos, Context &Ctx, const Twine &Name="")
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition Type.h:50
static LLVM_ABI IntegerType * getInt32Ty(Context &Ctx)
Definition Type.cpp:21
bool isVectorTy() const
True if this is an instance of VectorType.
Definition Type.h:214
Value * getOperand(unsigned OpIdx) const
Definition User.h:123
static std::optional< int > getPointerDiffInBytes(LoadOrStoreT *I0, LoadOrStoreT *I1, ScalarEvolution &SE)
\Returns the gap between the memory locations accessed by I0 and I1 in bytes.
Definition Utils.h:92
static unsigned getNumBits(Type *Ty, const DataLayout &DL)
\Returns the number of bits of Ty.
Definition Utils.h:66
static Type * getExpectedType(const Value *V)
\Returns the expected type of Value V.
Definition Utils.h:32
A SandboxIR Value has users. This is the base class.
Definition Value.h:72
LLVM_ABI Type * getType() const
Definition Value.cpp:46
Context & getContext() const
Definition Value.h:285
Iterate over all lanes and Value pairs.
Definition VecUtils.h:366
bool operator==(const LaneValueEnumerator &Other) const
Definition VecUtils.h:398
bool operator!=(const LaneValueEnumerator &Other) const
Definition VecUtils.h:401
std::pair< unsigned, Value * > value_type
Definition VecUtils.h:381
std::pair< unsigned, Value * > & reference
Definition VecUtils.h:384
LaneValueEnumerator(RangeIteratorT Begin, RangeIteratorT End, unsigned BeginLane)
Definition VecUtils.h:376
std::pair< unsigned, Value * > * pointer
Definition VecUtils.h:383
static Type * tryGetCommonScalarType(ArrayRef< Value * > Bndl)
If all values in Bndl are of the same scalar type then return it, otherwise return nullptr.
Definition VecUtils.h:220
static Instruction * getLowest(ArrayRef< Instruction * > Instrs)
\Returns the instruction in Instrs that is lowest in the BB.
Definition VecUtils.h:145
static Type * getCommonScalarType(ArrayRef< Value * > Bndl)
Similar to tryGetCommonScalarType() but will assert that there is a common type.
Definition VecUtils.h:236
static int getNumElements(Type *Ty)
\Returns the number of elements in Ty.
Definition VecUtils.h:45
static std::optional< PackPattern > matchPack(Instruction *I)
If I is the last instruction of a pack pattern (i.e., an InsertElement into a vector),...
Definition VecUtils.h:279
static Type * getCombinedVectorTypeFor(ArrayRef< Instruction * > Bndl, const DataLayout &DL)
\Returns the combined vector type for Bndl, even when the element types differ.
Definition VecUtils.h:124
static Instruction * getLastPHIOrSelf(Instruction *I)
If I is not a PHI it returns it.
Definition VecUtils.h:195
static unsigned getNumLanes(Type *Ty)
\Returns the number of vector lanes of Ty or 1 if not a vector.
Definition VecUtils.h:90
static Instruction * getLowest(ArrayRef< Value * > Vals, BasicBlock *BB)
\Returns the lowest instruction in Vals, or nullptr if no instructions are found.
Definition VecUtils.h:165
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:323
static LLVM_DUMP_METHOD void dump(ArrayRef< Value * > Bndl)
Helper dump function for debugging.
Definition VecUtils.cpp:111
static Type * getWideType(Type *ElemTy, unsigned NumElts)
\Returns <NumElts x ElemTy>.
Definition VecUtils.h:113
static Instruction * getHighest(ArrayRef< Instruction * > Instrs)
\Returns the instruction in Instrs that is highest in the BB.
Definition VecUtils.h:155
static auto enumerateLanes(const ValueContainerT &Range)
Helper for creating LaneValueEnumerator ranges.
Definition VecUtils.h:409
static bool areConsecutive(LoadOrStoreT *I1, LoadOrStoreT *I2, ScalarEvolution &SE, const DataLayout &DL)
\Returns true if I1 and I2 are load/stores accessing consecutive memory addresses.
Definition VecUtils.h:57
static bool areConsecutive(ArrayRef< ValT * > Bndl, ScalarEvolution &SE, const DataLayout &DL)
Definition VecUtils.h:70
static Type * getElementType(Type *Ty)
Returns Ty if scalar or its element type if vector.
Definition VecUtils.h:50
static unsigned getNumLanes(Value *V)
\Returns the expected vector lanes of V or 1 if not a vector.
Definition VecUtils.h:99
static unsigned getNumLanes(ArrayRef< Value * > Bndl)
\Returns the total number of lanes across all values in Bndl.
Definition VecUtils.h:104
static BasicBlock::iterator getInsertPointAfterInstrs(ArrayRef< Value * > Vals, BasicBlock *BB)
\Returns the BB iterator after the lowest instruction in Vals (skipping instructions not in BB),...
Definition VecUtils.h:207
static LLVM_ABI unsigned getFloorPowerOf2(unsigned Num)
\Returns the first integer power of 2 that is <= Num.
Definition VecUtils.cpp:96
static LLVM_ABI SmallVector< BundleTy > getNextUserBundles(ArrayRef< Value * > Bndl, const InstrMaps &IMaps, SmallPtrSet< Instruction *, 4 > &Claimed)
For each user of lane 0 in Bndl, try to form a bundle of matching users for all lanes.
Definition VecUtils.cpp:68
BasicBlock(llvm::BasicBlock *BB, Context &SBCtx)
Definition BasicBlock.h:75
SmallVector< Value *, 4 > BundleTy
Definition VecUtils.h:38
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition STLExtras.h:315
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
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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
@ Other
Any other memory.
Definition ModRef.h:68
DWARFExpression::Operation Op
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
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
Definition Sequence.h:341
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition Hashing.h:285
static bool isEqual(const SmallVector< sandboxir::Value * > &Vec1, const SmallVector< sandboxir::Value * > &Vec2)
Definition VecUtils.h:28
static unsigned getHashValue(const SmallVector< sandboxir::Value * > &Vec)
Definition VecUtils.h:25
An information struct used to provide DenseMap with the various necessary components for a given valu...
Helper struct for matchPack().
Definition VecUtils.h:256
SmallVector< Value * > Operands
The "external" operands of the pack pattern, i.e., the values that get packed into a vector,...
Definition VecUtils.h:269
SmallVector< Instruction * > Instrs
The insertelement instructions that form the pack pattern in bottom-up order, i.e....
Definition VecUtils.h:264