@@ -766,8 +766,8 @@ class ControlFlowHoister {
766
766
if (!ControlFlowHoisting)
767
767
return CurLoop->getLoopPreheader ();
768
768
// If BB has already been hoisted, return that
769
- if (HoistDestinationMap.count (BB))
770
- return HoistDestinationMap[BB] ;
769
+ if (auto It = HoistDestinationMap.find (BB); It != HoistDestinationMap. end ( ))
770
+ return It-> second ;
771
771
772
772
// Check if this block is conditional based on a pending branch
773
773
auto HasBBAsSuccessor =
@@ -800,11 +800,12 @@ class ControlFlowHoister {
800
800
801
801
// Create hoisted versions of blocks that currently don't have them
802
802
auto CreateHoistedBlock = [&](BasicBlock *Orig) {
803
- if (HoistDestinationMap.count (Orig))
804
- return HoistDestinationMap[Orig];
803
+ auto [It, Inserted] = HoistDestinationMap.try_emplace (Orig);
804
+ if (!Inserted)
805
+ return It->second ;
805
806
BasicBlock *New =
806
807
BasicBlock::Create (C, Orig->getName () + " .licm" , Orig->getParent ());
807
- HoistDestinationMap[Orig] = New;
808
+ It-> second = New;
808
809
DT->addNewBlock (New, HoistTarget);
809
810
if (CurLoop->getParentLoop ())
810
811
CurLoop->getParentLoop ()->addBasicBlockToLoop (New, *LI);
@@ -1531,14 +1532,11 @@ static Instruction *sinkThroughTriviallyReplaceablePHI(
1531
1532
assert (isTriviallyReplaceablePHI (*TPN, *I) &&
1532
1533
" Expect only trivially replaceable PHI" );
1533
1534
BasicBlock *ExitBlock = TPN->getParent ();
1534
- Instruction *New;
1535
- auto It = SunkCopies.find (ExitBlock);
1536
- if (It != SunkCopies.end ())
1537
- New = It->second ;
1538
- else
1539
- New = SunkCopies[ExitBlock] = cloneInstructionInExitBlock (
1540
- *I, *ExitBlock, *TPN, LI, SafetyInfo, MSSAU);
1541
- return New;
1535
+ auto [It, Inserted] = SunkCopies.try_emplace (ExitBlock);
1536
+ if (Inserted)
1537
+ It->second = cloneInstructionInExitBlock (*I, *ExitBlock, *TPN, LI,
1538
+ SafetyInfo, MSSAU);
1539
+ return It->second ;
1542
1540
}
1543
1541
1544
1542
static bool canSplitPredecessors (PHINode *PN, LoopSafetyInfo *SafetyInfo) {
0 commit comments