|
LLVM 24.0.0git
|
The base class for shuffle instruction emission and shuffle cost estimation. More...
#include "Transforms/Vectorize/SLPVectorizer/SLPShuffleAnalysis.h"
Protected Member Functions | |
| BaseShuffleAnalysis (Type *ScalarTy) | |
| unsigned | getVF (Value *V) const |
| V is expected to be a vectorized value. | |
Static Protected Member Functions | |
| static bool | isIdentityMask (ArrayRef< int > Mask, const FixedVectorType *VecTy, bool IsStrict) |
| Checks if the mask is an identity mask. | |
| static void | combineMasks (unsigned LocalVF, SmallVectorImpl< int > &Mask, ArrayRef< int > ExtMask) |
| Tries to combine 2 different masks into single one. | |
| static bool | peekThroughShuffles (Value *&V, SmallVectorImpl< int > &Mask, bool SinglePermute) |
| Looks through shuffles trying to reduce final number of shuffles in the code. | |
| template<typename T, typename ShuffleBuilderTy, typename... Args> | |
| static T | createShuffle (Value *V1, Value *V2, ArrayRef< int > Mask, ShuffleBuilderTy &Builder, Type *ScalarTy, bool ReVec, Args... Arguments) |
| Smart shuffle instruction emission, walks through shuffles trees and tries to find the best matching vector for the actual shuffle instruction. | |
| static void | transformMaskAfterShuffle (MutableArrayRef< int > CommonMask, ArrayRef< int > Mask) |
Transforms mask CommonMask per given Mask to make proper set after shuffle emission. | |
Protected Attributes | |
| Type * | ScalarTy = nullptr |
The base class for shuffle instruction emission and shuffle cost estimation.
Definition at line 36 of file SLPShuffleAnalysis.h.
|
inlineprotected |
Definition at line 40 of file SLPShuffleAnalysis.h.
References ScalarTy.
Referenced by slpvectorizer::BoUpSLP::ShuffleCostEstimator::ShuffleCostEstimator(), and slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleInstructionBuilder().
|
inlinestaticprotected |
Tries to combine 2 different masks into single one.
| LocalVF | Vector length of the permuted input vector. Mask may change the size of the vector, LocalVF is the original size of the shuffled vector. |
Definition at line 94 of file SLPShuffleAnalysis.h.
References I, llvm::PoisonMaskElem, and llvm::ArrayRef< T >::size().
Referenced by createShuffle(), and peekThroughShuffles().
|
inlinestaticprotected |
Smart shuffle instruction emission, walks through shuffles trees and tries to find the best matching vector for the actual shuffle instruction.
Definition at line 260 of file SLPShuffleAnalysis.h.
References Arguments, llvm::ArrayRef(), assert(), llvm::slpvectorizer::buildUseMask(), llvm::cast(), combineMasks(), llvm::dyn_cast(), E(), llvm::enumerate(), llvm::PoisonValue::get(), llvm::slpvectorizer::getNumElements(), llvm::Value::getType(), I, llvm::isa(), llvm::ShuffleVectorInst::isIdentityMask(), llvm::slpvectorizer::isUndefVector(), llvm::ShuffleVectorInst::isZeroEltSplatMask(), peekThroughShuffles(), llvm::PoisonMaskElem, ScalarTy, llvm::slpvectorizer::SecondArg, llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SmallVectorImpl< T >::swap(), T, llvm::slpvectorizer::transformScalarShuffleIndiciesToVector(), and llvm::V1.
V is expected to be a vectorized value.
When REVEC is disabled, there is no difference between VF and VNumElements. When REVEC is enabled, VF is VNumElements / ScalarTyNumElements. e.g., if ScalarTy is <4 x Ty> and V1 is <8 x Ty>, 2 is returned instead of 8.
Definition at line 48 of file SLPShuffleAnalysis.h.
References assert(), llvm::cast(), llvm::slpvectorizer::getNumElements(), llvm::isa(), and ScalarTy.
Referenced by slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::add(), and slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::add().
|
inlinestaticprotected |
Checks if the mask is an identity mask.
| IsStrict | if is true the function returns false if mask size does not match vector size. |
Definition at line 66 of file SLPShuffleAnalysis.h.
References llvm::all_of(), llvm::equal_to(), llvm::FixedVectorType::getNumElements(), llvm::ShuffleVectorInst::isExtractSubvectorMask(), llvm::ShuffleVectorInst::isIdentityMask(), llvm::PoisonMaskElem, and llvm::seq().
Referenced by peekThroughShuffles().
|
inlinestaticprotected |
Looks through shuffles trying to reduce final number of shuffles in the code.
The function looks through the previously emitted shuffle instructions and properly mark indices in mask as undef. For example, given the code
and if need to emit shuffle of s1 and s2 with mask <1, 0, 3, 2>, it will look through s1 and s2 and select vectors %0 and %1 with mask <0, 1, 2, 3> for the shuffle. If 2 operands are of different size, the smallest one will be resized and the mask recalculated properly. For example, given the code
and if need to emit shuffle of s1 and s2 with mask <1, 0, 5, 4>, it will look through s1 and s2 and select vectors %0 and %1 with mask <0, 1, 2, 3> for the shuffle. So, it tries to transform permutations to simple vector merge, if possible.
| V | The input vector which must be shuffled using the given Mask. If the better candidate is found, V is set to this best candidate vector. |
| Mask | The input mask for the shuffle. If the best candidate is found during looking-through-shuffles attempt, it is updated accordingly. |
| SinglePermute | true if the shuffle operation is originally a single-value-permutation. In this case the look-through-shuffles procedure may look for resizing shuffles as the best candidates. |
Definition at line 141 of file SLPShuffleAnalysis.h.
References llvm::all_of(), assert(), llvm::SmallVectorImpl< T >::assign(), llvm::slpvectorizer::buildUseMask(), llvm::cast(), combineMasks(), llvm::dyn_cast(), llvm::enumerate(), llvm::slpvectorizer::FirstArg, I, isIdentityMask(), llvm::slpvectorizer::isUndefVector(), llvm::ShuffleVectorInst::isZeroEltSplatMask(), P, llvm::PoisonMaskElem, llvm::slpvectorizer::SecondArg, and llvm::SmallVectorTemplateCommon< T, typename >::size().
Referenced by createShuffle().
|
inlinestaticprotected |
Transforms mask CommonMask per given Mask to make proper set after shuffle emission.
Definition at line 383 of file SLPShuffleAnalysis.h.
References I, llvm::PoisonMaskElem, llvm::seq(), and llvm::ArrayRef< T >::size().
Referenced by slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::add(), and slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::add().
|
protected |
Definition at line 38 of file SLPShuffleAnalysis.h.
Referenced by slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), slpvectorizer::BoUpSLP::ShuffleCostEstimator::add(), BaseShuffleAnalysis(), createShuffle(), slpvectorizer::BoUpSLP::ShuffleCostEstimator::gather(), slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::gather(), getVF(), slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::needToDelay(), slpvectorizer::BoUpSLP::ShuffleCostEstimator::ShuffleCostEstimator(), and slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleInstructionBuilder().