diff options
author | Matthew Simpson <mssimpso@codeaurora.org> | 2017-03-27 20:07:38 +0000 |
---|---|---|
committer | Matthew Simpson <mssimpso@codeaurora.org> | 2017-03-27 20:07:38 +0000 |
commit | b8ff4a4a700d3d24e20e98a1e849fd57c8b0bbd0 (patch) | |
tree | 277385dafe06ba57b510ab6af46a88ab7ecb1430 /llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | |
parent | 6ebeb7041e2294eb429389ea90f2467cb54fb7d5 (diff) | |
download | bcm5719-llvm-b8ff4a4a700d3d24e20e98a1e849fd57c8b0bbd0.tar.gz bcm5719-llvm-b8ff4a4a700d3d24e20e98a1e849fd57c8b0bbd0.zip |
[LV] Transform truncations of non-primary induction variables
The vectorizer tries to replace truncations of induction variables with new
induction variables having the smaller type. After r295063, this optimization
was applied to all integer induction variables, including non-primary ones.
When optimizing the truncation of a non-primary induction variable, we still
need to transform the new induction so that it has the correct start value.
This should fix PR32419.
Reference: https://bugs.llvm.org/show_bug.cgi?id=32419
llvm-svn: 298882
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoopVectorize.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index fa2c71dd802..af2d3f53064 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2521,22 +2521,21 @@ void InnerLoopVectorizer::widenIntOrFpInduction(PHINode *IV, TruncInst *Trunc) { // induction variable and step. Otherwise, derive these values from the // induction descriptor. if (!VectorizedIV || NeedsScalarIV) { + ScalarIV = Induction; + if (IV != OldInduction) { + ScalarIV = IV->getType()->isIntegerTy() + ? Builder.CreateSExtOrTrunc(Induction, IV->getType()) + : Builder.CreateCast(Instruction::SIToFP, Induction, + IV->getType()); + ScalarIV = ID.transform(Builder, ScalarIV, PSE.getSE(), DL); + ScalarIV->setName("offset.idx"); + } if (Trunc) { auto *TruncType = cast<IntegerType>(Trunc->getType()); assert(Step->getType()->isIntegerTy() && "Truncation requires an integer step"); - ScalarIV = Builder.CreateCast(Instruction::Trunc, Induction, TruncType); + ScalarIV = Builder.CreateTrunc(ScalarIV, TruncType); Step = Builder.CreateTrunc(Step, TruncType); - } else { - ScalarIV = Induction; - if (IV != OldInduction) { - ScalarIV = IV->getType()->isIntegerTy() - ? Builder.CreateSExtOrTrunc(ScalarIV, IV->getType()) - : Builder.CreateCast(Instruction::SIToFP, Induction, - IV->getType()); - ScalarIV = ID.transform(Builder, ScalarIV, PSE.getSE(), DL); - ScalarIV->setName("offset.idx"); - } } } |