diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 61242030e48..735dfd4c79d 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -4430,24 +4430,9 @@ void BoUpSLP::computeMinimumValueSizes() { // additional roots that require investigating in Roots. SmallVector<Value *, 32> ToDemote; SmallVector<Value *, 4> Roots; - for (auto *Root : TreeRoot) { - // Do not include top zext/sext/trunc operations to those to be demoted, it - // produces noise cast<vect>, trunc <vect>, exctract <vect>, cast <extract> - // sequence. - if (isa<Constant>(Root)) - continue; - auto *I = dyn_cast<Instruction>(Root); - if (!I || !I->hasOneUse() || !Expr.count(I)) - return; - if (isa<ZExtInst>(I) || isa<SExtInst>(I)) - continue; - if (auto *TI = dyn_cast<TruncInst>(I)) { - Roots.push_back(TI->getOperand(0)); - continue; - } + for (auto *Root : TreeRoot) if (!collectValuesToDemote(Root, Expr, ToDemote, Roots)) return; - } // The maximum bit width required to represent all the values that can be // demoted without loss of precision. It would be safe to truncate the roots @@ -4476,7 +4461,11 @@ void BoUpSLP::computeMinimumValueSizes() { // We start by looking at each entry that can be demoted. We compute the // maximum bit width required to store the scalar by using ValueTracking to // compute the number of high-order bits we can truncate. - if (MaxBitWidth == DL->getTypeSizeInBits(TreeRoot[0]->getType())) { + if (MaxBitWidth == DL->getTypeSizeInBits(TreeRoot[0]->getType()) && + llvm::all_of(TreeRoot, [](Value *R) { + assert(R->hasOneUse() && "Root should have only one use!"); + return isa<GetElementPtrInst>(R->user_back()); + })) { MaxBitWidth = 8u; // Determine if the sign bit of all the roots is known to be zero. If not, |