LLVM: lib/Transforms/Vectorize/VectorCombine.cpp File Reference (original) (raw)

Go to the source code of this file.

Macros
#define DEBUG_TYPE "vector-combine"
Typedefs
using InstLane = std::pair<Use *, int>
Functions
STATISTIC (NumVecLoad, "Number of vector loads formed")
STATISTIC (NumVecCmp, "Number of vector compares formed")
STATISTIC (NumVecBO, "Number of vector binops formed")
STATISTIC (NumVecCmpBO, "Number of vector compare + binop formed")
STATISTIC (NumShufOfBitcast, "Number of shuffles moved after bitcast")
STATISTIC (NumScalarOps, "Number of scalar unary + binary ops formed")
STATISTIC (NumScalarCmp, "Number of scalar compares formed")
STATISTIC (NumScalarIntrinsic, "Number of scalar intrinsic calls formed")
static Value * peekThroughBitcasts (Value *V)
Return the source operand of a potentially bitcasted value.
static bool canWidenLoad (LoadInst *Load, const TargetTransformInfo &TTI)
static Value * createShiftShuffle (Value *Vec, unsigned OldIndex, unsigned NewIndex, IRBuilderBase &Builder)
Create a shuffle that translates (shifts) 1 element from the input vector to a new element location.
static Value * translateExtract (ExtractElementInst *ExtElt, unsigned NewIndex, IRBuilderBase &Builder)
Given an extract element instruction with constant index operand, shuffle the source vector (shift the scalar element) to a NewIndex for extraction.
static void analyzeCostOfVecReduction (const IntrinsicInst &II, TTI::TargetCostKind CostKind, const TargetTransformInfo &TTI, InstructionCost &CostBeforeReduction, InstructionCost &CostAfterReduction)
static bool isMemModifiedBetween (BasicBlock::iterator Begin, BasicBlock::iterator End, const MemoryLocation &Loc, AAResults &AA)
static ScalarizationResult canScalarizeAccess (VectorType *VecTy, Value *Idx, Instruction *CtxI, AssumptionCache &AC, const DominatorTree &DT)
Check if it is legal to scalarize a memory access to VecTy at index Idx.
static Align computeAlignmentAfterScalarization (Align VectorAlignment, Type *ScalarType, Value *Idx, const DataLayout &DL)
The memory operation on a vector of ScalarType had alignment of VectorAlignment.
static InstLane lookThroughShuffles (Use *U, int Lane)
static SmallVector< InstLane > generateInstLaneVectorFromOperand (ArrayRef< InstLane > Item, int Op)
static bool isFreeConcat (ArrayRef< InstLane > Item, TTI::TargetCostKind CostKind, const TargetTransformInfo &TTI)
Detect concat of multiple values into a vector.
static Value * generateNewInstTree (ArrayRef< InstLane > Item, FixedVectorType *Ty, const SmallPtrSet< Use *, 4 > &IdentityLeafs, const SmallPtrSet< Use *, 4 > &SplatLeafs, const SmallPtrSet< Use *, 4 > &ConcatLeafs, IRBuilderBase &Builder, const TargetTransformInfo *TTI)
static bool feedsIntoVectorReduction (ShuffleVectorInst *SVI)
Returns true if this ShuffleVectorInst eventually feeds into a vector reduction intrinsic (e.g., vector_reduce_add) by only following chains of shuffles and binary operators (in any combination/order).

DEBUG_TYPE

#define DEBUG_TYPE "vector-combine"

InstLane

using InstLane = std::pair<Use *, int>

analyzeCostOfVecReduction()

Definition at line 1548 of file VectorCombine.cpp.

References llvm::cast(), CostKind, llvm::dyn_cast(), llvm::VectorType::get(), llvm::getArithmeticReductionInstruction(), llvm::Instruction::getOpcode(), llvm::User::getOperand(), llvm::Value::getType(), II, llvm::isa(), llvm::PatternMatch::m_Instruction(), llvm::PatternMatch::m_Mul(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_ZExtOrSExt(), llvm::PatternMatch::match(), and llvm::TargetTransformInfo::None.

canScalarizeAccess()

Check if it is legal to scalarize a memory access to VecTy at index Idx.

Idx must access a valid vector element.

Definition at line 1734 of file VectorCombine.cpp.

References llvm::ConstantRange::binaryAnd(), llvm::CallingConv::C, llvm::computeConstantRange(), llvm::ConstantRange::contains(), llvm::dyn_cast(), llvm::Type::getScalarSizeInBits(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::isGuaranteedNotToBePoison(), llvm::isUIntN(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_ConstantInt(), llvm::PatternMatch::m_URem(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), and llvm::ConstantRange::urem().

canWidenLoad()

computeAlignmentAfterScalarization()

createShiftShuffle()

feedsIntoVectorReduction()

Returns true if this ShuffleVectorInst eventually feeds into a vector reduction intrinsic (e.g., vector_reduce_add) by only following chains of shuffles and binary operators (in any combination/order).

The search does not go deeper than the given Depth.

Definition at line 3813 of file VectorCombine.cpp.

References llvm::cast(), llvm::dyn_cast(), llvm::SmallVectorImpl< T >::emplace_back(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), I, II, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::isa(), llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallPtrSetImplBase::size().

generateInstLaneVectorFromOperand()

generateNewInstTree()

Definition at line 3111 of file VectorCombine.cpp.

References AbstractManglingParser< Derived, Alloc >::NumOps, AbstractManglingParser< Derived, Alloc >::Ops, assert(), llvm::cast(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::dyn_cast(), llvm::ArrayRef< T >::front(), generateInstLaneVectorFromOperand(), generateNewInstTree(), llvm::FixedVectorType::get(), I, II, llvm::isa(), llvm::isVectorIntrinsicWithScalarOpAtArg(), llvm::propagateIRFlags(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::ArrayRef< T >::size(), and llvm::SmallVectorTemplateCommon< T, typename >::size().

Referenced by generateNewInstTree().

isFreeConcat()

Detect concat of multiple values into a vector.

Definition at line 3077 of file VectorCombine.cpp.

References llvm::SmallVectorTemplateCommon< T, typename >::begin(), llvm::cast(), CostKind, llvm::SmallVectorTemplateCommon< T, typename >::end(), llvm::ArrayRef< T >::front(), llvm::FixedVectorType::get(), llvm::Value::getType(), llvm::isPowerOf2_32(), llvm::ArrayRef< T >::size(), and llvm::TargetTransformInfo::SK_PermuteTwoSrc.

isMemModifiedBetween()

lookThroughShuffles()

InstLane lookThroughShuffles ( Use * U, int Lane ) static

peekThroughBitcasts()

STATISTIC() [1/8]

STATISTIC ( NumScalarCmp ,
"Number of scalar compares formed" )

STATISTIC() [2/8]

STATISTIC ( NumScalarIntrinsic ,
"Number of scalar intrinsic calls formed" )

STATISTIC() [3/8]

STATISTIC ( NumScalarOps ,
"Number of scalar unary + binary ops formed" )

STATISTIC() [4/8]

STATISTIC ( NumShufOfBitcast ,
"Number of shuffles moved after bitcast" )

STATISTIC() [5/8]

STATISTIC ( NumVecBO ,
"Number of vector binops formed" )

STATISTIC() [6/8]

STATISTIC ( NumVecCmp ,
"Number of vector compares formed" )

STATISTIC() [7/8]

STATISTIC ( NumVecCmpBO ,
"Number of vector compare + binop formed" )

STATISTIC() [8/8]

STATISTIC ( NumVecLoad ,
"Number of vector loads formed" )

translateExtract()

DisableBinopExtractShuffle

cl::opt< bool > DisableBinopExtractShuffle("disable-binop-extract-shuffle", cl::init(false), cl::Hidden, cl::desc("Disable binop extract to shuffle transforms")) ( "disable-binop-extract-shuffle" , cl::init(false) , cl::Hidden , cl::desc("Disable binop extract to shuffle transforms") ) static

DisableVectorCombine

cl::opt< bool > DisableVectorCombine("disable-vector-combine", cl::init(false), cl::Hidden, cl::desc("Disable all vector combine transforms")) ( "disable-vector-combine" , cl::init(false) , cl::Hidden , cl::desc("Disable all vector combine transforms") ) static

InvalidIndex

MaxInstrsToScan