diff options
| author | Michael Kuperstein <mkuper@google.com> | 2017-02-06 21:50:59 +0000 |
|---|---|---|
| committer | Michael Kuperstein <mkuper@google.com> | 2017-02-06 21:50:59 +0000 |
| commit | 7a86bb258904eb4f283a281ab0f4d756f7684c86 (patch) | |
| tree | 607939b184af24e37896657f90834698f876b9f8 /llvm/lib/Transforms/Vectorize | |
| parent | 250858a01e6dc70e885282b043d22f4f6880be31 (diff) | |
| download | bcm5719-llvm-7a86bb258904eb4f283a281ab0f4d756f7684c86.tar.gz bcm5719-llvm-7a86bb258904eb4f283a281ab0f4d756f7684c86.zip | |
[SLP] Revert "Allow using of extra values in horizontal reductions."
This breaks when one of the extra values is also a scalar that
participates in the same vectorization tree which we'll end up
reducing.
llvm-svn: 294245
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 79 |
1 files changed, 12 insertions, 67 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index dc64c39d385..b1dce3c89a5 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -4189,8 +4189,6 @@ namespace { class HorizontalReduction { SmallVector<Value *, 16> ReductionOps; SmallVector<Value *, 32> ReducedVals; - // Use map vector to make stable output. - MapVector<Value *, Value *> ExtraArgs; BinaryOperator *ReductionRoot = nullptr; // After successfull horizontal reduction vectorization attempt for PHI node @@ -4210,26 +4208,6 @@ class HorizontalReduction { /// splits the vector in halves and adds those halves. bool IsPairwiseReduction = false; - /// Checks if the ParentStackElem.first should be marked as a reduction - /// operation with an extra argument or as extra argument itself. - void markExtraArg(std::pair<Instruction *, unsigned> &ParentStackElem, - Value *ExtraArg) { - if (ExtraArgs.count(ParentStackElem.first)) { - ExtraArgs[ParentStackElem.first] = nullptr; - // We ran into something like: - // ParentStackElem.first = ExtraArgs[ParentStackElem.first] + ExtraArg. - // The whole ParentStackElem.first should be considered as an extra value - // in this case. - // Do not perform analysis of remaining operands of ParentStackElem.first - // instruction, this whole instruction is an extra argument. - ParentStackElem.second = ParentStackElem.first->getNumOperands(); - } else { - // We ran into something like: - // ParentStackElem.first += ... + ExtraArg + ... - ExtraArgs[ParentStackElem.first] = ExtraArg; - } - } - public: HorizontalReduction() = default; @@ -4282,23 +4260,8 @@ public: if (EdgeToVist == 2 || IsReducedValue) { if (IsReducedValue) ReducedVals.push_back(TreeN); - else { - auto I = ExtraArgs.find(TreeN); - if (I != ExtraArgs.end() && !I->second) { - // Check if TreeN is an extra argument of its parent operation. - if (Stack.size() <= 1) { - // TreeN can't be an extra argument as it is a root reduction - // operation. - return false; - } - // Yes, TreeN is an extra argument, do not add it to a list of - // reduction operations. - // Stack[Stack.size() - 2] always points to the parent operation. - markExtraArg(Stack[Stack.size() - 2], TreeN); - ExtraArgs.erase(TreeN); - } else - ReductionOps.push_back(TreeN); - } + else + ReductionOps.push_back(TreeN); // Retract. Stack.pop_back(); continue; @@ -4315,42 +4278,30 @@ public: if (I && (!ReducedValueOpcode || I->getOpcode() == ReducedValueOpcode || I->getOpcode() == ReductionOpcode)) { // Only handle trees in the current basic block. - if (I->getParent() != B->getParent()) { - // I is an extra argument for TreeN (its parent operation). - markExtraArg(Stack.back(), I); - continue; - } + if (I->getParent() != B->getParent()) + return false; // Each tree node needs to have one user except for the ultimate // reduction. - if (!I->hasOneUse() && I != B) { - // I is an extra argument for TreeN (its parent operation). - markExtraArg(Stack.back(), I); - continue; - } + if (!I->hasOneUse() && I != B) + return false; if (I->getOpcode() == ReductionOpcode) { // We need to be able to reassociate the reduction operations. - if (!I->isAssociative()) { - // I is an extra argument for TreeN (its parent operation). - markExtraArg(Stack.back(), I); - continue; - } + if (!I->isAssociative()) + return false; } else if (ReducedValueOpcode && ReducedValueOpcode != I->getOpcode()) { // Make sure that the opcodes of the operations that we are going to // reduce match. - // I is an extra argument for TreeN (its parent operation). - markExtraArg(Stack.back(), I); - continue; + return false; } else if (!ReducedValueOpcode) ReducedValueOpcode = I->getOpcode(); Stack.push_back(std::make_pair(I, 0)); continue; } - // NextV is an extra argument for TreeN (its parent operation). - markExtraArg(Stack.back(), NextV); + return false; } } return true; @@ -4419,16 +4370,10 @@ public: if (VectorizedTree) { // Finish the reduction. for (; i < NumReducedVals; ++i) { - auto *I = cast<Instruction>(ReducedVals[i]); - Builder.SetCurrentDebugLocation(I->getDebugLoc()); - VectorizedTree = - Builder.CreateBinOp(ReductionOpcode, VectorizedTree, I); - } - for (auto &Pair : ExtraArgs) { Builder.SetCurrentDebugLocation( - cast<Instruction>(Pair.first)->getDebugLoc()); + cast<Instruction>(ReducedVals[i])->getDebugLoc()); VectorizedTree = Builder.CreateBinOp(ReductionOpcode, VectorizedTree, - Pair.second, "bin.extra"); + ReducedVals[i]); } // Update users. if (ReductionPHI && !isa<UndefValue>(ReductionPHI)) { |

