From b60736ec1405bb0a8dd40989f67ef4c93da068ab Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Tue, 16 Feb 2021 21:13:02 +0100 Subject: Vendor import of llvm-project main 8e464dd76bef, the last commit before the upstream release/12.x branch was created. --- llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp') 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 &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(FLI); @@ -1130,8 +1128,8 @@ bool InterleavedLoadCombineImpl::combine(std::list &InterleavedLoad, std::set Is; std::set 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 &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 &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++; } -- cgit v1.3