summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-06-09 18:03:15 +0000
committerMichael Kuperstein <mkuper@google.com>2016-06-09 18:03:15 +0000
commitc5edcdeb0e4eb20ada6b25a4d6ebd0d9e484ada6 (patch)
treee36abdebde9385fbd651d9acd8faed9d65dc8358 /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
parentca8c994818f1e18c1290c9d64893a76a376f0941 (diff)
downloadbcm5719-llvm-c5edcdeb0e4eb20ada6b25a4d6ebd0d9e484ada6.tar.gz
bcm5719-llvm-c5edcdeb0e4eb20ada6b25a4d6ebd0d9e484ada6.zip
[LV] Use vector phis for some secondary induction variables
Previously, we materialized secondary vector IVs from the primary scalar IV, by offseting the primary to match the correct start value, and then broadcasting it - inside the loop body. Instead, we can use a real vector IV, like we do for the primary. This enables using vector IVs for secondary integer IVs whose type matches the type of the primary. Differential Revision: http://reviews.llvm.org/D20932 llvm-svn: 272283
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 144eab58f74..0203f6218e4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -423,8 +423,8 @@ protected:
virtual Value *getStepVector(Value *Val, int StartIdx, const SCEV *Step);
/// Create a vector induction variable based on an existing scalar one.
- /// Currently only works for integer primary induction variables with
- /// a constant step.
+ /// Currently only works for integer induction variables with a constant
+ /// step.
/// If TruncType is provided, instead of widening the original IV, we
/// widen a version of the IV truncated to TruncType.
void widenInductionVariable(const InductionDescriptor &II, VectorParts &Entry,
@@ -2126,7 +2126,8 @@ void InnerLoopVectorizer::widenInductionVariable(const InductionDescriptor &II,
Builder.restoreIP(CurrIP);
Value *SplatVF =
- ConstantVector::getSplat(VF, ConstantInt::get(Start->getType(), VF));
+ ConstantVector::getSplat(VF, ConstantInt::getSigned(Start->getType(),
+ VF * Step->getSExtValue()));
// We may need to add the step a number of times, depending on the unroll
// factor. The last of those goes into the PHI.
PHINode *VecInd = PHINode::Create(SteppedStart->getType(), 2, "vec.ind",
@@ -4098,7 +4099,8 @@ void InnerLoopVectorizer::widenPHIInstruction(
llvm_unreachable("Unknown induction");
case InductionDescriptor::IK_IntInduction: {
assert(P->getType() == II.getStartValue()->getType() && "Types must match");
- if (P != OldInduction || VF == 1) {
+ if (VF == 1 || P->getType() != Induction->getType() ||
+ !II.getConstIntStepValue()) {
Value *V = Induction;
// Handle other induction variables that are now based on the
// canonical one.
OpenPOWER on IntegriCloud