mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-02 00:16:25 +00:00
[SLPVectorizer] Refactor where MinVecRegSize and MaxVecRegSize live.
This is the first of two commits for extending SLP Vectorizer to deal with aggregates. This commit merely refactors existing logic. http://reviews.llvm.org/D14185 llvm-svn: 267748
This commit is contained in:
parent
19cd041163
commit
eb3c90d715
@ -373,6 +373,18 @@ public:
|
|||||||
SE(Se), TTI(Tti), TLI(TLi), AA(Aa), LI(Li), DT(Dt), AC(AC), DB(DB),
|
SE(Se), TTI(Tti), TLI(TLi), AA(Aa), LI(Li), DT(Dt), AC(AC), DB(DB),
|
||||||
DL(DL), Builder(Se->getContext()) {
|
DL(DL), Builder(Se->getContext()) {
|
||||||
CodeMetrics::collectEphemeralValues(F, AC, EphValues);
|
CodeMetrics::collectEphemeralValues(F, AC, EphValues);
|
||||||
|
// Use the vector register size specified by the target unless overridden
|
||||||
|
// by a command-line option.
|
||||||
|
// TODO: It would be better to limit the vectorization factor based on
|
||||||
|
// data type rather than just register size. For example, x86 AVX has
|
||||||
|
// 256-bit registers, but it does not support integer operations
|
||||||
|
// at that width (that requires AVX2).
|
||||||
|
if (MaxVectorRegSizeOption.getNumOccurrences())
|
||||||
|
MaxVecRegSize = MaxVectorRegSizeOption;
|
||||||
|
else
|
||||||
|
MaxVecRegSize = TTI->getRegisterBitWidth(true);
|
||||||
|
|
||||||
|
MinVecRegSize = MinVectorRegSizeOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Vectorize the tree that starts with the elements in \p VL.
|
/// \brief Vectorize the tree that starts with the elements in \p VL.
|
||||||
@ -426,6 +438,16 @@ public:
|
|||||||
/// vectorizable tree.
|
/// vectorizable tree.
|
||||||
void computeMinimumValueSizes();
|
void computeMinimumValueSizes();
|
||||||
|
|
||||||
|
// \returns maximum vector register size as set by TTI or overridden by cl::opt.
|
||||||
|
unsigned getMaxVecRegSize() const {
|
||||||
|
return MaxVecRegSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// \returns minimum vector register size as set by cl::opt.
|
||||||
|
unsigned getMinVecRegSize() const {
|
||||||
|
return MinVecRegSize;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct TreeEntry;
|
struct TreeEntry;
|
||||||
|
|
||||||
@ -926,6 +948,8 @@ private:
|
|||||||
AssumptionCache *AC;
|
AssumptionCache *AC;
|
||||||
DemandedBits *DB;
|
DemandedBits *DB;
|
||||||
const DataLayout *DL;
|
const DataLayout *DL;
|
||||||
|
unsigned MaxVecRegSize; // This is set by TTI or overridden by cl::opt.
|
||||||
|
unsigned MinVecRegSize; // Set by cl::opt (default: 128).
|
||||||
/// Instruction builder to construct the vectorized tree.
|
/// Instruction builder to construct the vectorized tree.
|
||||||
IRBuilder<> Builder;
|
IRBuilder<> Builder;
|
||||||
|
|
||||||
@ -3419,19 +3443,6 @@ struct SLPVectorizer : public FunctionPass {
|
|||||||
if (!TTI->getNumberOfRegisters(true))
|
if (!TTI->getNumberOfRegisters(true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Use the vector register size specified by the target unless overridden
|
|
||||||
// by a command-line option.
|
|
||||||
// TODO: It would be better to limit the vectorization factor based on
|
|
||||||
// data type rather than just register size. For example, x86 AVX has
|
|
||||||
// 256-bit registers, but it does not support integer operations
|
|
||||||
// at that width (that requires AVX2).
|
|
||||||
if (MaxVectorRegSizeOption.getNumOccurrences())
|
|
||||||
MaxVecRegSize = MaxVectorRegSizeOption;
|
|
||||||
else
|
|
||||||
MaxVecRegSize = TTI->getRegisterBitWidth(true);
|
|
||||||
|
|
||||||
MinVecRegSize = MinVectorRegSizeOption;
|
|
||||||
|
|
||||||
// Don't vectorize when the attribute NoImplicitFloat is used.
|
// Don't vectorize when the attribute NoImplicitFloat is used.
|
||||||
if (F.hasFnAttribute(Attribute::NoImplicitFloat))
|
if (F.hasFnAttribute(Attribute::NoImplicitFloat))
|
||||||
return false;
|
return false;
|
||||||
@ -3539,9 +3550,6 @@ private:
|
|||||||
|
|
||||||
/// The getelementptr instructions in a basic block organized by base pointer.
|
/// The getelementptr instructions in a basic block organized by base pointer.
|
||||||
WeakVHListMap GEPs;
|
WeakVHListMap GEPs;
|
||||||
|
|
||||||
unsigned MaxVecRegSize; // This is set by TTI or overridden by cl::opt.
|
|
||||||
unsigned MinVecRegSize; // Set by cl::opt (default: 128).
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Check that the Values in the slice in VL array are still existent in
|
/// \brief Check that the Values in the slice in VL array are still existent in
|
||||||
@ -3659,7 +3667,7 @@ bool SLPVectorizer::vectorizeStores(ArrayRef<StoreInst *> Stores,
|
|||||||
|
|
||||||
// FIXME: Is division-by-2 the correct step? Should we assert that the
|
// FIXME: Is division-by-2 the correct step? Should we assert that the
|
||||||
// register size is a power-of-2?
|
// register size is a power-of-2?
|
||||||
for (unsigned Size = MaxVecRegSize; Size >= MinVecRegSize; Size /= 2) {
|
for (unsigned Size = R.getMaxVecRegSize(); Size >= R.getMinVecRegSize(); Size /= 2) {
|
||||||
if (vectorizeStoreChain(Operands, costThreshold, R, Size)) {
|
if (vectorizeStoreChain(Operands, costThreshold, R, Size)) {
|
||||||
// Mark the vectorized stores so that we don't vectorize them again.
|
// Mark the vectorized stores so that we don't vectorize them again.
|
||||||
VectorizedStores.insert(Operands.begin(), Operands.end());
|
VectorizedStores.insert(Operands.begin(), Operands.end());
|
||||||
@ -3732,7 +3740,7 @@ bool SLPVectorizer::tryToVectorizeList(ArrayRef<Value *> VL, BoUpSLP &R,
|
|||||||
// FIXME: Register size should be a parameter to this function, so we can
|
// FIXME: Register size should be a parameter to this function, so we can
|
||||||
// try different vectorization factors.
|
// try different vectorization factors.
|
||||||
unsigned Sz = R.getVectorElementSize(I0);
|
unsigned Sz = R.getVectorElementSize(I0);
|
||||||
unsigned VF = MinVecRegSize / Sz;
|
unsigned VF = R.getMinVecRegSize() / Sz;
|
||||||
|
|
||||||
for (Value *V : VL) {
|
for (Value *V : VL) {
|
||||||
Type *Ty = V->getType();
|
Type *Ty = V->getType();
|
||||||
@ -4358,7 +4366,7 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Try to match and vectorize a horizontal reduction.
|
// Try to match and vectorize a horizontal reduction.
|
||||||
if (canMatchHorizontalReduction(P, BI, R, TTI, MinVecRegSize)) {
|
if (canMatchHorizontalReduction(P, BI, R, TTI, R.getMinVecRegSize())) {
|
||||||
Changed = true;
|
Changed = true;
|
||||||
it = BB->begin();
|
it = BB->begin();
|
||||||
e = BB->end();
|
e = BB->end();
|
||||||
@ -4386,7 +4394,7 @@ bool SLPVectorizer::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
|
|||||||
if (BinaryOperator *BinOp =
|
if (BinaryOperator *BinOp =
|
||||||
dyn_cast<BinaryOperator>(SI->getValueOperand())) {
|
dyn_cast<BinaryOperator>(SI->getValueOperand())) {
|
||||||
if (canMatchHorizontalReduction(nullptr, BinOp, R, TTI,
|
if (canMatchHorizontalReduction(nullptr, BinOp, R, TTI,
|
||||||
MinVecRegSize) ||
|
R.getMinVecRegSize()) ||
|
||||||
tryToVectorize(BinOp, R)) {
|
tryToVectorize(BinOp, R)) {
|
||||||
Changed = true;
|
Changed = true;
|
||||||
it = BB->begin();
|
it = BB->begin();
|
||||||
|
Loading…
Reference in New Issue
Block a user