LLVM 23.0.0git
llvm::slpvectorizer Namespace Reference

A private "module" namespace for types and utilities used by this pass. More...

Classes

class  BoUpSLP
 Bottom Up SLP Vectorizer. More...

Functions

bool isConstant (Value *V)
bool isVectorLikeInstWithConstOps (Value *V)
 Checks if V is one of vector-like instructions, i.e.
unsigned getNumElements (Type *Ty)
unsigned getPartNumElems (unsigned Size, unsigned NumParts)
 Returns power-of-2 number of elements in a single register (part), given the total number of elements Size and number of registers (parts) NumParts.
unsigned getNumElems (unsigned Size, unsigned PartNumElems, unsigned Part)
 Returns correct remaining number of elements, considering total amount Size, (power-of-2 number) of elements in a single register PartNumElems and current register (part) Part.
bool allSameBlock (ArrayRef< Value * > VL)
bool allConstant (ArrayRef< Value * > VL)
bool isSplat (ArrayRef< Value * > VL)
bool allSameOpcode (ArrayRef< Value * > VL)
std::optional< unsignedgetExtractIndex (const Instruction *E)
bool allSameType (ArrayRef< Value * > VL)
template<typename T>
std::optional< unsignedgetInsertExtractIndex (const Value *Inst, unsigned Offset)
template std::optional< unsignedgetInsertExtractIndex< InsertElementInst > (const Value *, unsigned)
template std::optional< unsignedgetInsertExtractIndex< ExtractElementInst > (const Value *, unsigned)

Detailed Description

A private "module" namespace for types and utilities used by this pass.

These are implementation details and should not be used by clients.

Function Documentation

◆ allConstant()

bool llvm::slpvectorizer::allConstant ( ArrayRef< Value * > VL)
Returns
True if all of the values in VL are constants (but not globals/constant expressions).

Definition at line 84 of file SLPUtils.cpp.

References llvm::all_of(), and isConstant().

Referenced by slpvectorizer::BoUpSLP::getReorderingData(), slpvectorizer::BoUpSLP::getSpillCost(), slpvectorizer::BoUpSLP::isTreeNotExtendable(), and slpvectorizer::BoUpSLP::isTreeTinyAndNotFullyVectorizable().

◆ allSameBlock()

◆ allSameOpcode()

bool llvm::slpvectorizer::allSameOpcode ( ArrayRef< Value * > VL)
Returns
True if all of the values in VL use the same opcode. For comparison instructions, also checks if predicates match. PoisonValues are considered matching. Interchangeable instructions are not considered.

Definition at line 105 of file SLPUtils.cpp.

References llvm::CmpInst::BAD_ICMP_PREDICATE, llvm::cast(), llvm::ArrayRef< T >::end(), llvm::find_if(), llvm::Instruction::getOpcode(), llvm::isa(), and llvm::IsaPred.

Referenced by getSameOpcode().

◆ allSameType()

bool llvm::slpvectorizer::allSameType ( ArrayRef< Value * > VL)
Returns
True iff every value in VL has the same Type as the first.

Definition at line 147 of file SLPUtils.cpp.

References llvm::all_of(), and llvm::ArrayRef< T >::consume_front().

Referenced by slpvectorizer::BoUpSLP::buildTree(), slpvectorizer::BoUpSLP::buildTree(), and slpvectorizer::BoUpSLP::getReorderingData().

◆ getExtractIndex()

std::optional< unsigned > llvm::slpvectorizer::getExtractIndex ( const Instruction * E)
Returns
Optional element Idx for Extract{Value,Element} instructions.

Definition at line 123 of file SLPUtils.cpp.

References assert(), llvm::cast(), llvm::dyn_cast(), and getNumElements().

Referenced by slpvectorizer::BoUpSLP::getReorderingData().

◆ getInsertExtractIndex()

template<typename T>
std::optional< unsigned > llvm::slpvectorizer::getInsertExtractIndex ( const Value * Inst,
unsigned Offset )
Returns
inserting or extracting index of InsertElement / ExtractElement instruction, using Offset as base offset for index. Only instantiated for InsertElementInst and ExtractElementInst (see SLPUtils.cpp).

Definition at line 153 of file SLPUtils.cpp.

References llvm::dyn_cast(), and llvm::Offset.

Referenced by getElementIndex().

◆ getInsertExtractIndex< ExtractElementInst >()

◆ getInsertExtractIndex< InsertElementInst >()

◆ getNumElements()

◆ getNumElems()

unsigned llvm::slpvectorizer::getNumElems ( unsigned Size,
unsigned PartNumElems,
unsigned Part )

Returns correct remaining number of elements, considering total amount Size, (power-of-2 number) of elements in a single register PartNumElems and current register (part) Part.

Definition at line 58 of file SLPUtils.cpp.

References Size.

Referenced by slpvectorizer::BoUpSLP::findReusedOrderedScalars(), and slpvectorizer::BoUpSLP::processBuildVector().

◆ getPartNumElems()

unsigned llvm::slpvectorizer::getPartNumElems ( unsigned Size,
unsigned NumParts )

Returns power-of-2 number of elements in a single register (part), given the total number of elements Size and number of registers (parts) NumParts.

Definition at line 54 of file SLPUtils.cpp.

References llvm::bit_ceil(), llvm::divideCeil(), and Size.

Referenced by slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), slpvectorizer::BoUpSLP::findReusedOrderedScalars(), and slpvectorizer::BoUpSLP::processBuildVector().

◆ isConstant()

bool llvm::slpvectorizer::isConstant ( Value * V)
Returns
True if the value is a constant (but not globals/constant expressions).

Definition at line 25 of file SLPUtils.cpp.

References llvm::isa().

Referenced by allConstant(), areCompatibleCmpOps(), arePointersCompatible(), slpvectorizer::BoUpSLP::findReusedOrderedScalars(), and isVectorLikeInstWithConstOps().

◆ isSplat()

bool llvm::slpvectorizer::isSplat ( ArrayRef< Value * > VL)
Returns
True if all of the values in VL are identical or some of them are UndefValue.

Definition at line 90 of file SLPUtils.cpp.

References llvm::isa().

Referenced by llvm::DOTGraphTraits< BoUpSLP * >::getNodeLabel(), and slpvectorizer::BoUpSLP::getReorderingData().

◆ isVectorLikeInstWithConstOps()

bool llvm::slpvectorizer::isVectorLikeInstWithConstOps ( Value * V)

Checks if V is one of vector-like instructions, i.e.

undef, insertelement/extractelement with constant indices for fixed vector type or extractvalue instruction.

Definition at line 29 of file SLPUtils.cpp.

References assert(), llvm::dyn_cast(), I, llvm::isa(), and isConstant().

Referenced by allSameBlock(), generateKeySubkey(), getSameOpcode(), and tryToFindDuplicates().