diff options
author | Matthew Simpson <mssimpso@codeaurora.org> | 2016-09-30 15:13:52 +0000 |
---|---|---|
committer | Matthew Simpson <mssimpso@codeaurora.org> | 2016-09-30 15:13:52 +0000 |
commit | 7808833e28be784dfad2f66ed0bc3cdc05e30db2 (patch) | |
tree | 588251b04e4fc195bab3219cdba1e190689792fb /llvm/lib/Transforms | |
parent | 7ca05307c92f2d5d7dc317f5fc676edbfad0fdcd (diff) | |
download | bcm5719-llvm-7808833e28be784dfad2f66ed0bc3cdc05e30db2.tar.gz bcm5719-llvm-7808833e28be784dfad2f66ed0bc3cdc05e30db2.zip |
[LV] Build all scalar steps for non-uniform induction variables
When building the steps for scalar induction variables, we previously attempted
to determine if all the scalar users of the induction variable were uniform. If
they were, we would only emit the step corresponding to vector lane zero. This
optimization was too aggressive. We generally don't know the entire set of
induction variable users that will be scalar. We have
isScalarAfterVectorization, but this is only a conservative estimate of the
instructions that will be scalarized. Thus, an induction variable may have
scalar users that aren't already known to be scalar. To avoid emitting unused
steps, we can only check that the induction variable is uniform. This should
fix PR30542.
Reference: https://llvm.org/bugs/show_bug.cgi?id=30542
llvm-svn: 282863
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 897d14a1404..c2282705313 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2326,22 +2326,11 @@ void InnerLoopVectorizer::buildScalarSteps(Value *ScalarIV, Value *Step, assert(ScalarIVTy->isIntegerTy() && ScalarIVTy == Step->getType() && "Val and Step should have the same integer type"); - auto scalarUserIsUniform = [&](User *U) -> bool { - auto *I = cast<Instruction>(U); - return !OrigLoop->contains(I) || !Legal->isScalarAfterVectorization(I) || - Legal->isUniformAfterVectorization(I); - }; - // Determine the number of scalars we need to generate for each unroll - // iteration. If EntryVal is uniform or all it's scalar users are uniform, we - // only need to generate the first lane. Otherwise, we generate all VF - // values. We are essentially determining if the induction variable has no - // "multi-scalar" (non-uniform scalar) users. + // iteration. If EntryVal is uniform, we only need to generate the first + // lane. Otherwise, we generate all VF values. unsigned Lanes = - Legal->isUniformAfterVectorization(cast<Instruction>(EntryVal)) || - all_of(EntryVal->users(), scalarUserIsUniform) - ? 1 - : VF; + Legal->isUniformAfterVectorization(cast<Instruction>(EntryVal)) ? 1 : VF; // Compute the scalar steps and save the results in VectorLoopValueMap. ScalarParts Entry(UF); |