diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
| commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
| tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp | |
| parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
Diffstat (limited to 'llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp index f7131926ee65..ff3f93d51ea8 100644 --- a/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp +++ b/llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp @@ -1104,10 +1104,8 @@ InterleavedLoadCombineImpl::findFirstLoad(const std::set<LoadInst *> &LIs) { // All LIs are within the same BB. Select the first for a reference. BasicBlock *BB = (*LIs.begin())->getParent(); - BasicBlock::iterator FLI = - std::find_if(BB->begin(), BB->end(), [&LIs](Instruction &I) -> bool { - return is_contained(LIs, &I); - }); + BasicBlock::iterator FLI = llvm::find_if( + *BB, [&LIs](Instruction &I) -> bool { return is_contained(LIs, &I); }); assert(FLI != BB->end()); return cast<LoadInst>(FLI); @@ -1130,8 +1128,8 @@ bool InterleavedLoadCombineImpl::combine(std::list<VectorInfo> &InterleavedLoad, std::set<Instruction *> Is; std::set<Instruction *> SVIs; - unsigned InterleavedCost; - unsigned InstructionCost = 0; + InstructionCost InterleavedCost; + InstructionCost InstructionCost = 0; // Get the interleave factor unsigned Factor = InterleavedLoad.size(); @@ -1174,6 +1172,10 @@ bool InterleavedLoadCombineImpl::combine(std::list<VectorInfo> &InterleavedLoad, } } + // We need to have a valid cost in order to proceed. + if (!InstructionCost.isValid()) + return false; + // We know that all LoadInst are within the same BB. This guarantees that // either everything or nothing is loaded. LoadInst *First = findFirstLoad(LIs); @@ -1236,8 +1238,7 @@ bool InterleavedLoadCombineImpl::combine(std::list<VectorInfo> &InterleavedLoad, Mask.push_back(i + j * Factor); Builder.SetInsertPoint(VI.SVI); - auto SVI = Builder.CreateShuffleVector(LI, UndefValue::get(LI->getType()), - Mask, "interleaved.shuffle"); + auto SVI = Builder.CreateShuffleVector(LI, Mask, "interleaved.shuffle"); VI.SVI->replaceAllUsesWith(SVI); i++; } |
