File tree Expand file tree Collapse file tree 1 file changed +15
-21
lines changed
Expand file tree Collapse file tree 1 file changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -954,29 +954,23 @@ void InlineHelper::InlineAndOptimize(CallInst* callInst)
954954 // Merge static array allocas to reduce the use of private
955955 // memory. This is a similar optimization that exists in
956956 // the inliner, see mergeInlinedArrayAllocas().
957- if (perFnAllocas. empty ())
958- {
959- for (AllocaInst* allocaInst : IFI. StaticAllocas )
957+ llvm::erase_if (
958+ IFI. StaticAllocas ,
959+ [] (AllocaInst* I )
960960 {
961- if (!allocaInst->isArrayAllocation () &&
962- allocaInst->getAllocatedType ()->isArrayTy ())
963- {
964- perFnAllocas.push_back (allocaInst);
965- }
961+ return I->isArrayAllocation () || !I->getAllocatedType ()->isArrayTy ();
966962 }
967- }
968- else
963+ );
964+
965+ auto staticAlloca = IFI.StaticAllocas .begin ();
966+ for (auto * fnAlloca : perFnAllocas)
969967 {
970- auto it = perFnAllocas.begin ();
971- for (AllocaInst* allocaInst : IFI.StaticAllocas )
972- {
973- if (!allocaInst->isArrayAllocation () &&
974- allocaInst->getAllocatedType ()->isArrayTy ())
975- {
976- IGC_ASSERT ((*it)->getAllocatedType () == allocaInst->getAllocatedType ());
977- allocaInst->replaceAllUsesWith (*it);
978- ++it;
979- }
980- }
968+ if ((*staticAlloca)->getAllocatedType () == fnAlloca->getAllocatedType ())
969+ (*staticAlloca)->replaceAllUsesWith (fnAlloca);
970+
971+ if (++staticAlloca == IFI.StaticAllocas .end ())
972+ return ;
981973 }
974+
975+ perFnAllocas.append (staticAlloca, IFI.StaticAllocas .end ());
982976}
You can’t perform that action at this time.
0 commit comments