LLVM 24.0.0git
SLPUtils.h
Go to the documentation of this file.
1//===- SLPUtils.h - SLP Vectorizer free utility helpers --------*- 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// Internal header used by SLPVectorizer.cpp. It declares free helper
10// functions that do not depend on BoUpSLP, InstructionsState, or any other
11// SLP-private type. Splitting them out keeps SLPVectorizer.cpp focused on
12// the build / legality / cost / codegen pipeline.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPUTILS_H
17#define LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPUTILS_H
18
19#include "llvm/ADT/APInt.h"
20#include "llvm/ADT/ArrayRef.h"
26#include "llvm/IR/Intrinsics.h"
27
28#include <optional>
29#include <string>
30
31namespace llvm {
32class AssumptionCache;
33class Constant;
34class DataLayout;
35class Instruction;
36class IRBuilderBase;
38class Type;
39class Value;
40} // namespace llvm
41
42namespace llvm::slpvectorizer {
43
44/// Limit of the number of uses for potentially transformed instructions/values,
45/// used in checks to avoid compile-time explode.
46inline constexpr int UsesLimit = 64;
47
48/// \returns True if the value is a constant (but not globals/constant
49/// expressions).
50bool isConstant(Value *V);
51
52/// \returns True if \p V is the integer identity constant for binary \p Opcode
53/// (e.g. 0 for add, 1 for mul, all-ones for and). Floating-point identities are
54/// excluded: a ConstantInt never matches the ConstantFP getBinOpIdentity()
55/// returns for FAdd/FMul, whose identity fast-math may break anyway.
56bool isBinOpIdentityConstant(const Value *V, unsigned Opcode);
57
58/// \returns the opcode of the combines emitted for a reassociated node:
59/// subtract chains regroup their positive and negative operand columns with
60/// plain adds.
61unsigned getReassocCombineOpcode(unsigned Opcode);
62
63/// \returns True if \p I can be a link of a flattenable binary chain:
64/// subtracts flatten as adds of a negated leaf, float subtracts need reassoc
65/// to allow the regrouping.
67
68/// Checks if \p V is one of vector-like instructions, i.e. undef,
69/// insertelement/extractelement with constant indices for fixed vector type
70/// or extractvalue instruction.
72
73/// \returns the number of elements for Ty.
74unsigned getNumElements(Type *Ty);
75
76/// Returns power-of-2 number of elements in a single register (part), given
77/// the total number of elements \p Size and number of registers (parts) \p
78/// NumParts.
79unsigned getPartNumElems(unsigned Size, unsigned NumParts);
80
81/// Returns correct remaining number of elements, considering total amount
82/// \p Size, (power-of-2 number) of elements in a single register
83/// \p PartNumElems and current register (part) \p Part.
84unsigned getNumElems(unsigned Size, unsigned PartNumElems, unsigned Part);
85
86#if !defined(NDEBUG)
87/// Print a short descriptor of the instruction bundle suitable for debug
88/// output.
89std::string shortBundleName(ArrayRef<Value *> VL, int Idx = -1);
90#endif
91
92/// \returns True if all of the instructions in \p VL are in the same block.
94
95/// \returns True if all of the values in \p VL are constants (but not
96/// globals/constant expressions).
98
99/// \returns True if all of the values in \p VL are identical or some of them
100/// are UndefValue.
102
103/// Checks if \p LHS and \p RHS are the same intrinsic, or one is llvm.fma
104/// and the other is llvm.fmuladd, since both lower to the same fused
105/// vector operation.
106/// \returns the intrinsic ID to use for the pair (\p RHS if the IDs match,
107/// otherwise Intrinsic::fma), or Intrinsic::not_intrinsic if they are not
108/// equivalent.
110
111/// \returns True if \p I is commutative, handles CmpInst and BinaryOperator.
112/// For BinaryOperator, it also checks if \p ValWithUses is used in specific
113/// patterns that make it effectively commutative (like equality comparisons
114/// with zero).
115/// In most cases, users should not call this function directly (since \p I and
116/// \p ValWithUses are the same). However, when analyzing interchangeable
117/// instructions, we need to use the converted opcode along with the original
118/// uses.
119/// \param I The instruction to check for commutativity
120/// \param ValWithUses The value whose uses are analyzed for special
121/// patterns
122bool isCommutative(const Instruction *I, const Value *ValWithUses,
123 bool IsCopyable = false);
124
125/// This is a helper function to check whether \p I is commutative.
126/// This is a convenience wrapper that calls the two-parameter version of
127/// isCommutative with the same instruction for both parameters. This is
128/// the common case where the instruction being checked for commutativity
129/// is the same as the instruction whose uses are analyzed for special
130/// patterns (see the two-parameter version above for details).
131/// \param I The instruction to check for commutativity
132/// \returns true if the instruction is commutative, false otherwise
133bool isCommutative(const Instruction *I);
134
135/// Checks if the operand is commutative. In commutative operations, not all
136/// operands might commutable, e.g. for fmuladd only 2 first operands are
137/// commutable.
138bool isCommutableOperand(const Instruction *I, Value *ValWithUses, unsigned Op,
139 bool IsCopyable = false);
140
141/// \returns number of operands of \p I, considering commutativity. Returns 2
142/// for commutative intrinsics.
143/// \param I The instruction to check for commutativity
145
146/// \returns inserting or extracting index of InsertElement, ExtractElement
147/// or InsertValue instruction, using \p Offset as base offset for index.
148/// \returns std::nullopt if the index is not an immediate.
149std::optional<unsigned> getElementIndex(const Value *Inst, unsigned Offset = 0);
150
151/// \returns True if all of the values in \p VL use the same opcode.
152/// For comparison instructions, also checks if predicates match.
153/// PoisonValues are considered matching. Interchangeable instructions are
154/// not considered.
156
157/// \returns Optional element Idx for Extract{Value,Element} instructions.
158std::optional<unsigned> getExtractIndex(const Instruction *E);
159
160/// Compute the inverse permutation \p Mask of \p Indices.
162
163/// Reorders the list of scalars in accordance with the given \p Mask.
165
166/// Reorders the given \p Reuses mask according to the given \p Mask. \p Reuses
167/// contains original mask for the scalars reused in the node. Procedure
168/// transform this mask in accordance with the given \p Mask.
170
171/// Reorders the given \p Order according to the given \p Mask. \p Order - is
172/// the original order of the scalars. Procedure transforms the provided order
173/// in accordance with the given \p Mask. If the resulting \p Order is just an
174/// identity order, \p Order is cleared.
176 bool BottomOrder = false);
177
178/// Check if \p Order represents reverse order.
180
181/// Checks if the given mask is a "clustered" mask with the same clusters of
182/// size \p Sz, which are not identity submasks.
184
185/// Fills unset elements of \p Order (marked with the sentinel value equal to
186/// the order size) with the corresponding elements of \p SecondaryOrder,
187/// skipping already used indices, or with the identity order if
188/// \p SecondaryOrder is empty.
190 ArrayRef<unsigned> SecondaryOrder);
191
192/// \returns True iff every value in \p VL has the same Type as the first.
194
195/// Checks if the provided value does not require scheduling. It does not
196/// require scheduling if this is not an instruction or it is an instruction
197/// that does not read/write memory and all operands are either not
198/// instructions or phi nodes or instructions from different blocks.
200
201/// Checks if the provided value does not require scheduling. It does not
202/// require scheduling if this is not an instruction or it is an instruction
203/// that does not read/write memory and all users are phi nodes or
204/// instructions from different blocks.
206
207/// Checks if the specified value does not require scheduling. It does not
208/// require scheduling if all operands and all users do not need to be
209/// scheduled in the current basic block.
211
212/// Checks if the specified array of instructions does not require scheduling.
213/// It is so if all either instructions have operands that do not require
214/// scheduling or their users do not require scheduling since they are phis or
215/// in other basic blocks.
217
218/// \returns inserting or extracting index of InsertElement / ExtractElement
219/// instruction, using \p Offset as base offset for index. Only instantiated
220/// for InsertElementInst and ExtractElementInst (see SLPUtils.cpp).
221template <typename T>
222std::optional<unsigned> getInsertExtractIndex(const Value *Inst,
223 unsigned Offset);
224
225void transformScalarShuffleIndiciesToVector(unsigned VecTyNumElements,
227
228/// \returns the number of groups of shufflevector
229/// A group has the following features
230/// 1. All of value in a group are shufflevector.
231/// 2. The mask of all shufflevector is isExtractSubvectorMask.
232/// 3. The mask of all shufflevector uses all of the elements of the source.
233/// e.g., it is 1 group (%0)
234/// %1 = shufflevector <16 x i8> %0, <16 x i8> poison,
235/// <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
236/// %2 = shufflevector <16 x i8> %0, <16 x i8> poison,
237/// <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
238/// it is 2 groups (%3 and %4)
239/// %5 = shufflevector <8 x i16> %3, <8 x i16> poison,
240/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
241/// %6 = shufflevector <8 x i16> %3, <8 x i16> poison,
242/// <4 x i32> <i32 4, i32 5, i32 6, i32 7>
243/// %7 = shufflevector <8 x i16> %4, <8 x i16> poison,
244/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
245/// %8 = shufflevector <8 x i16> %4, <8 x i16> poison,
246/// <4 x i32> <i32 4, i32 5, i32 6, i32 7>
247/// it is 0 group
248/// %12 = shufflevector <8 x i16> %10, <8 x i16> poison,
249/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
250/// %13 = shufflevector <8 x i16> %11, <8 x i16> poison,
251/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
253
254/// \returns a shufflevector mask which is used to vectorize shufflevectors
255/// e.g.,
256/// %5 = shufflevector <8 x i16> %3, <8 x i16> poison,
257/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
258/// %6 = shufflevector <8 x i16> %3, <8 x i16> poison,
259/// <4 x i32> <i32 4, i32 5, i32 6, i32 7>
260/// %7 = shufflevector <8 x i16> %4, <8 x i16> poison,
261/// <4 x i32> <i32 0, i32 1, i32 2, i32 3>
262/// %8 = shufflevector <8 x i16> %4, <8 x i16> poison,
263/// <4 x i32> <i32 4, i32 5, i32 6, i32 7>
264/// the result is
265/// <0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31>
267
268/// Checks if the values in \p VL can be represented as a shuffle of at most
269/// two vector operands (extractelement lanes). On success, \p Mask is the
270/// equivalent shuffle mask.
271std::optional<TargetTransformInfo::ShuffleKind>
273 AssumptionCache *AC);
274
275/// Creates subvector insert. Generates shuffle using \p Generator or
276/// using default shuffle.
278 IRBuilderBase &Builder, Value *Vec, Value *V, unsigned Index,
279 function_ref<Value *(Value *, Value *, ArrayRef<int>)> Generator = {});
280
281/// Generates subvector extract using \p Generator or using default shuffle.
283 unsigned SubVecVF, unsigned Index);
284
285/// Specifies the way the mask should be analyzed for undefs/poisonous elements
286/// in the shuffle mask.
287enum class UseMask {
288 FirstArg, ///< The mask is expected to be for permutation of 1-2 vectors,
289 ///< check for the mask elements for the first argument (mask
290 ///< indices are in range [0:VF)).
291 SecondArg, ///< The mask is expected to be for permutation of 2 vectors, check
292 ///< for the mask elements for the second argument (mask indices
293 ///< are in range [VF:2*VF))
294 UndefsAsMask ///< Consider undef mask elements (-1) as placeholders for
295 ///< future shuffle elements and mark them as ones as being used
296 ///< in future. Non-undef elements are considered as unused since
297 ///< they're already marked as used in the mask.
298};
299
300/// Prepares a use bitset for the given mask either for the first argument or
301/// for the second.
302SmallBitVector buildUseMask(int VF, ArrayRef<int> Mask, UseMask MaskArg);
303
304/// Checks if the given value is actually an undefined constant vector.
305/// Also, if the \p UseMask is not empty, tries to check if the non-masked
306/// elements actually mask the insertelement buildvector, if any.
307template <bool IsPoisonOnly = false>
309 const SmallBitVector &UseMask = {});
310
311/// \returns True if in-tree use also needs extract. This refers to
312/// possible scalar operand in vectorized instruction.
313bool doesInTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst,
314 TargetLibraryInfo *TLI,
315 const TargetTransformInfo *TTI);
316
317/// \returns the AA location that is being access by the instruction.
318MemoryLocation getLocation(Instruction *I);
319
320/// \returns True if the instruction is not a volatile or atomic load/store.
321bool isSimple(Instruction *I);
322
323/// Checks if the loads with scalar type \p ScalarTy and pointer operands
324/// \p PointerOps are each (optionally via a constant-offset GEP) a
325/// `select Cond, A, B` picking between the same two base pointers A/B on
326/// every lane - the shape a fully unrolled `x = cond ? A[i] : B[i]` takes. On
327/// success \p TrueBase / \p FalseBase are the candidate bases and
328/// \p Conditions holds each lane's `select` condition, used to build the
329/// blend mask. Lane \p Idx must be at `Base + Idx * sizeof(ScalarTy)`; only
330/// dense, natural lane order starting at the base is recognized (reordered or
331/// partial groups fall back to Gather/Scatter).
332bool isSelectedBaseLoad(Type *ScalarTy, ArrayRef<Value *> PointerOps,
333 const DataLayout &DL, Value *&TrueBase,
334 Value *&FalseBase,
335 SmallVectorImpl<Value *> &Conditions);
336
337/// Shuffles \p Mask in accordance with the given \p SubMask.
338/// \param ExtendingManyInputs Supports reshuffling of the mask with not only
339/// one but two input vectors.
340void addMask(SmallVectorImpl<int> &Mask, ArrayRef<int> SubMask,
341 bool ExtendingManyInputs = false);
342
343/// Order may have elements assigned special value (size) which is out of
344/// bounds. Such indices only appear on places which correspond to undef values
345/// (see canReuseExtract for details) and used in order to avoid undef values
346/// have effect on operands ordering.
347/// The first loop below simply finds all unused indices and then the next loop
348/// nest assigns these indices for undef values positions.
349/// As an example below Order has two undef positions and they have assigned
350/// values 3 and 7 respectively:
351/// before: 6 9 5 4 9 2 1 0
352/// after: 6 3 5 4 7 2 1 0
354
355/// \returns a bitset for selecting opcodes. false for Opcode0 and true for
356/// Opcode1.
357SmallBitVector getAltInstrMask(ArrayRef<Value *> VL, Type *ScalarTy,
358 unsigned Opcode0, unsigned Opcode1);
359
360/// Replicates the given \p Val \p VF times.
362
363/// \returns the masked division/remainder intrinsic corresponding to \p
364/// Opcode. Disabled lanes of these intrinsics are poison rather than UB,
365/// unlike the plain opcode.
367
368/// Returns true if \p I forms a vectorizable bundle on its own and its single
369/// user does not tear the vector apart. Loads and addresses are excluded: the
370/// tree is built without the users, so it does not pay off the extracts. A
371/// cast, feeding a multi-used cast, is excluded for the same reason, such a
372/// user stays scalar. The fp-to-int conversions move the result to the other
373/// register domain, so the extracts are paid on top of the repacking. The
374/// values, feeding the inserts, are vectorized together with them by the
375/// dedicated attempt.
376bool isOnceUsedSeed(const Instruction *I);
377
378/// If \p V is a single-use fpext of a single-use fptrunc forming a round-trip
379/// back to the type of \p V, returns the fptrunc; the round-trip source is its
380/// operand, always an instruction of the same type as \p V. If
381/// \p MustBeElidable, matches only when the intermediate rounding may be
382/// removed: both casts must allow contraction and the widening cast cannot
383/// produce nan/inf.
384Instruction *lookThroughCastRoundTrip(Value *V, bool MustBeElidable);
385
386/// Narrow reduction leaf: the value, the shift applied after widening and
387/// the mask applied in the narrow type before widening, clearing the bits
388/// the absorbed narrow shls shift out and applying the absorbed narrow
389/// and-masks. Lossless narrow shls contribute their known-zero bits to the
390/// mask so matching lanes can form a splat. All-ones mask means nothing
391/// was absorbed and no 'and' is needed.
395
397 unsigned Shift;
399};
400
401/// Recursively collects the narrow leaves of the widened reduction value
402/// \p V. zext is looked through directly, same-kind binops per operand,
403/// shl of a zext - only if no bits are shifted out in the current type,
404/// shls in narrower types fold into the shift and ands with a constant into
405/// the mask applied in the narrow type. Also collects the looked-through
406/// instructions into \p ChainInsts.
407void collectNarrowedLeaves(Value *V, unsigned RdxOpcode, unsigned WideBW,
408 unsigned MaxDepth,
411
413
414} // namespace llvm::slpvectorizer
415
416#endif // LLVM_LIB_TRANSFORMS_VECTORIZE_SLPVECTORIZER_SLPUTILS_H
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
This file provides utility analysis objects describing memory locations.
This file implements the SmallBitVector class.
This file defines the SmallVector class.
This pass exposes codegen information to IR-level passes.
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
A cache of @llvm.assume calls within a function.
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
TargetCostKind
The kind of cost model.
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 efficient, type-erasing, non-owning reference to a callable.
A private "module" namespace for types and utilities used by this pass.
std::optional< unsigned > getExtractIndex(const Instruction *E)
Definition SLPUtils.cpp:276
Value * createInsertVector(IRBuilderBase &Builder, Value *Vec, Value *V, unsigned Index, function_ref< Value *(Value *, Value *, ArrayRef< int >)> Generator)
Creates subvector insert.
Definition SLPUtils.cpp:676
bool areAllOperandsNonInsts(Value *V)
Checks if the provided value does not require scheduling.
Definition SLPUtils.cpp:456
std::optional< unsigned > getElementIndex(const Value *Inst, unsigned Offset)
Definition SLPUtils.cpp:230
bool doesInTreeUserNeedToExtract(Value *Scalar, Instruction *UserInst, TargetLibraryInfo *TLI, const TargetTransformInfo *TTI)
Definition SLPUtils.cpp:779
MemoryLocation getLocation(Instruction *I)
Definition SLPUtils.cpp:807
bool isSelectedBaseLoad(Type *ScalarTy, ArrayRef< Value * > PointerOps, const DataLayout &DL, Value *&TrueBase, Value *&FalseBase, SmallVectorImpl< Value * > &Conditions)
Checks if the loads with scalar type ScalarTy and pointer operands PointerOps are each (optionally vi...
Definition SLPUtils.cpp:825
SmallBitVector getAltInstrMask(ArrayRef< Value * > VL, Type *ScalarTy, unsigned Opcode0, unsigned Opcode1)
Definition SLPUtils.cpp:914
SmallBitVector isUndefVector(const Value *V, const SmallBitVector &UseMask)
Checks if the given value is actually an undefined constant vector.
Definition SLPUtils.cpp:729
Intrinsic::ID getMaskedDivRemIntrinsic(unsigned Opcode)
Definition SLPUtils.cpp:937
bool isUsedOutsideBlock(Value *V)
Checks if the provided value does not require scheduling.
Definition SLPUtils.cpp:469
bool doesNotNeedToSchedule(ArrayRef< Value * > VL)
Checks if the specified array of instructions does not require scheduling.
Definition SLPUtils.cpp:487
std::optional< unsigned > getInsertExtractIndex(const Value *Inst, unsigned Offset)
Definition SLPUtils.cpp:423
void reorderScalars(SmallVectorImpl< Value * > &Scalars, ArrayRef< int > Mask)
Reorders the list of scalars in accordance with the given Mask.
Definition SLPUtils.cpp:309
bool allSameType(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:416
void combineOrders(MutableArrayRef< unsigned > Order, ArrayRef< unsigned > SecondaryOrder)
Fills unset elements of Order (marked with the sentinel value equal to the order size) with the corre...
Definition SLPUtils.cpp:394
bool allSameOpcode(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:258
bool isSplat(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:141
unsigned getNumElements(Type *Ty)
Definition SLPUtils.cpp:86
std::string shortBundleName(ArrayRef< Value * > VL, int Idx)
Print a short descriptor of the instruction bundle suitable for debug output.
Definition SLPUtils.cpp:103
bool isOnceUsedSeed(const Instruction *I)
Returns true if I forms a vectorizable bundle on its own and its single user does not tear the vector...
Definition SLPUtils.cpp:979
unsigned getPartNumElems(unsigned Size, unsigned NumParts)
Returns power-of-2 number of elements in a single register (part), given the total number of elements...
Definition SLPUtils.cpp:94
bool isCommutableOperand(const Instruction *I, Value *ValWithUses, unsigned Op, bool IsCopyable)
Checks if the operand is commutative.
Definition SLPUtils.cpp:202
TargetTransformInfo::TargetCostKind getSLPCostKind(const Function *F)
bool isReverseOrder(ArrayRef< unsigned > Order)
Check if Order represents reverse order.
Definition SLPUtils.cpp:373
void transformScalarShuffleIndiciesToVector(unsigned VecTyNumElements, SmallVectorImpl< int > &Mask)
Definition SLPUtils.cpp:492
SmallVector< int > calculateShufflevectorMask(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:547
SmallBitVector buildUseMask(int VF, ArrayRef< int > Mask, UseMask MaskArg)
Prepares a use bitset for the given mask either for the first argument or for the second.
Definition SLPUtils.cpp:712
bool isCommutative(const Instruction *I, const Value *ValWithUses, bool IsCopyable)
Definition SLPUtils.cpp:165
unsigned getNumberOfPotentiallyCommutativeOps(Instruction *I)
Definition SLPUtils.cpp:220
bool allConstant(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:135
void inversePermutation(ArrayRef< unsigned > Indices, SmallVectorImpl< int > &Mask)
Compute the inverse permutation Mask of Indices.
Definition SLPUtils.cpp:300
bool allSameBlock(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:113
bool isReassocChainLink(const Instruction *I)
Definition SLPUtils.cpp:58
Intrinsic::ID isEquivalentIntrinsicID(Intrinsic::ID LHS, Intrinsic::ID RHS)
Checks if LHS and RHS are the same intrinsic, or one is llvm.fma and the other is llvm....
Definition SLPUtils.cpp:156
UseMask
Specifies the way the mask should be analyzed for undefs/poisonous elements in the shuffle mask.
Definition SLPUtils.h:287
@ SecondArg
The mask is expected to be for permutation of 2 vectors, check for the mask elements for the second a...
Definition SLPUtils.h:291
@ UndefsAsMask
Consider undef mask elements (-1) as placeholders for future shuffle elements and mark them as ones a...
Definition SLPUtils.h:294
@ FirstArg
The mask is expected to be for permutation of 1-2 vectors, check for the mask elements for the first ...
Definition SLPUtils.h:288
void reorderOrder(SmallVectorImpl< unsigned > &Order, ArrayRef< int > Mask, bool BottomOrder)
Reorders the given Order according to the given Mask.
Definition SLPUtils.cpp:329
void reorderReuses(SmallVectorImpl< int > &Reuses, ArrayRef< int > Mask)
Reorders the given Reuses mask according to the given Mask.
Definition SLPUtils.cpp:319
void addMask(SmallVectorImpl< int > &Mask, ArrayRef< int > SubMask, bool ExtendingManyInputs)
Shuffles Mask in accordance with the given SubMask.
Definition SLPUtils.cpp:865
bool isSimple(Instruction *I)
Definition SLPUtils.cpp:815
Instruction * lookThroughCastRoundTrip(Value *V, bool MustBeElidable)
If V is a single-use fpext of a single-use fptrunc forming a round-trip back to the type of V,...
bool isBinOpIdentityConstant(const Value *V, unsigned Opcode)
Definition SLPUtils.cpp:42
unsigned getShufflevectorNumGroups(ArrayRef< Value * > VL)
Definition SLPUtils.cpp:507
std::optional< TargetTransformInfo::ShuffleKind > isFixedVectorShuffle(ArrayRef< Value * > VL, SmallVectorImpl< int > &Mask, AssumptionCache *AC)
Checks if the vector of instructions can be represented as a shuffle, like: x0 = extractelement <4 x ...
Definition SLPUtils.cpp:587
SmallVector< Constant * > replicateMask(ArrayRef< Constant * > Val, unsigned VF)
Replicates the given Val VF times.
Definition SLPUtils.cpp:928
unsigned getReassocCombineOpcode(unsigned Opcode)
Definition SLPUtils.cpp:47
bool isVectorLikeInstWithConstOps(Value *V)
Checks if V is one of vector-like instructions, i.e.
Definition SLPUtils.cpp:66
bool doesNotNeedToBeScheduled(Value *V)
Checks if the specified value does not require scheduling.
Definition SLPUtils.cpp:483
unsigned getNumElems(unsigned Size, unsigned PartNumElems, unsigned Part)
Returns correct remaining number of elements, considering total amount Size, (power-of-2 number) of e...
Definition SLPUtils.cpp:98
constexpr int UsesLimit
Limit of the number of uses for potentially transformed instructions/values, used in checks to avoid ...
Definition SLPUtils.h:46
void collectNarrowedLeaves(Value *V, unsigned RdxOpcode, unsigned WideBW, unsigned MaxDepth, SmallVectorImpl< NarrowedLeafInfo > &Leaves, SmallVectorImpl< Instruction * > &ChainInsts)
Recursively collects the narrow leaves of the widened reduction value V.
bool isRepeatedNonIdentityClusteredMask(ArrayRef< int > Mask, unsigned Sz)
Checks if the given mask is a "clustered" mask with the same clusters of size Sz, which are not ident...
Definition SLPUtils.cpp:382
bool isConstant(Value *V)
Definition SLPUtils.cpp:38
Value * createExtractVector(IRBuilderBase &Builder, Value *Vec, unsigned SubVecVF, unsigned Index)
Generates subvector extract using Generator or using default shuffle.
Definition SLPUtils.cpp:705
void fixupOrderingIndices(MutableArrayRef< unsigned > Order)
Order may have elements assigned special value (size) which is out of bounds.
Definition SLPUtils.cpp:890
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
TargetTransformInfo TTI
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
NarrowedLeafInfo(Value *V, unsigned Shift, APInt Mask)
Definition SLPUtils.h:393