summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorMichael Zolotukhin <mzolotukhin@apple.com>2015-07-08 21:47:53 +0000
committerMichael Zolotukhin <mzolotukhin@apple.com>2015-07-08 21:47:53 +0000
commit00345cadd5b2620adaa4f8b03fd56638bff945f8 (patch)
tree4fb914cce9a8848a5e3b8bb1f80091b281d1ab75 /llvm/lib/Transforms
parent7db3063f8799b64441ab4d30849c9f34eb951ab8 (diff)
downloadbcm5719-llvm-00345cadd5b2620adaa4f8b03fd56638bff945f8.tar.gz
bcm5719-llvm-00345cadd5b2620adaa4f8b03fd56638bff945f8.zip
[LoopVectorizer] Move some code around to ease further refactoring. NFCI.
llvm-svn: 241739
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f1f18613d9e..0a3f8bfe44b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2615,6 +2615,19 @@ void InnerLoopVectorizer::createEmptyLoop() {
// times the unroll factor (num of SIMD instructions).
Constant *Step = ConstantInt::get(IdxTy, VF * UF);
+ // Generate code to check that the loop's trip count that we computed by
+ // adding one to the backedge-taken count will not overflow.
+ auto PastOverflowCheck = std::next(BasicBlock::iterator(OverflowCheckAnchor));
+ BasicBlock *CheckBlock =
+ BypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
+ if (ParentLoop)
+ ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
+ LoopBypassBlocks.push_back(CheckBlock);
+ ReplaceInstWithInst(
+ BypassBlock->getTerminator(),
+ BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow));
+ BypassBlock = CheckBlock;
+
// This is the IR builder that we use to add all of the logic for bypassing
// the new vector loop.
IRBuilder<> BypassBuilder(BypassBlock->getTerminator());
@@ -2647,22 +2660,6 @@ void InnerLoopVectorizer::createEmptyLoop() {
Value *Cmp =
BypassBuilder.CreateICmpEQ(IdxEndRoundDown, StartIdx, "cmp.zero");
- // Generate code to check that the loops trip count that we computed by adding
- // one to the backedge-taken count will not overflow.
- {
- auto PastOverflowCheck =
- std::next(BasicBlock::iterator(OverflowCheckAnchor));
- BasicBlock *CheckBlock =
- BypassBlock->splitBasicBlock(PastOverflowCheck, "overflow.checked");
- if (ParentLoop)
- ParentLoop->addBasicBlockToLoop(CheckBlock, *LI);
- LoopBypassBlocks.push_back(CheckBlock);
- ReplaceInstWithInst(
- BypassBlock->getTerminator(),
- BranchInst::Create(ScalarPH, CheckBlock, CheckBCOverflow));
- BypassBlock = CheckBlock;
- }
-
// Generate the code to check that the strides we assumed to be one are really
// one. We want the new basic block to start at the first instruction in a
// sequence of instructions that form a check.
OpenPOWER on IntegriCloud