@@ -976,8 +976,8 @@ bool SimplifyCFGOpt::simplifyEqualityComparisonWithOnlyPredecessor(
976976 SwitchInstProfUpdateWrapper SI = *cast<SwitchInst>(TI);
977977 // Okay, TI has cases that are statically dead, prune them away.
978978 SmallPtrSet<Constant *, 16 > DeadCases;
979- for (unsigned i = 0 , e = PredCases. size (); i != e; ++i )
980- DeadCases.insert (PredCases[i] .Value );
979+ for (const ValueEqualityComparisonCase &Case : PredCases)
980+ DeadCases.insert (Case .Value );
981981
982982 LLVM_DEBUG (dbgs () << " Threading pred instr: " << *Pred->getTerminator ()
983983 << " Through successor TI: " << *TI);
@@ -1307,14 +1307,14 @@ bool SimplifyCFGOpt::performValueComparisonIntoPredecessorFolding(
13071307
13081308 // Okay, now we know which constants were sent to BB from the
13091309 // predecessor. Figure out where they will all go now.
1310- for (unsigned i = 0 , e = BBCases. size (); i != e; ++i )
1311- if (PTIHandled.count (BBCases[i] .Value )) {
1310+ for (const ValueEqualityComparisonCase &Case : BBCases)
1311+ if (PTIHandled.count (Case .Value )) {
13121312 // If this is one we are capable of getting...
13131313 if (PredHasWeights || SuccHasWeights)
1314- Weights.push_back (WeightsForHandled[BBCases[i] .Value ]);
1315- PredCases.push_back (BBCases[i] );
1316- ++NewSuccessors[BBCases[i] .Dest ];
1317- PTIHandled.erase (BBCases[i] .Value ); // This constant is taken care of
1314+ Weights.push_back (WeightsForHandled[Case .Value ]);
1315+ PredCases.push_back (Case );
1316+ ++NewSuccessors[Case .Dest ];
1317+ PTIHandled.erase (Case .Value ); // This constant is taken care of
13181318 }
13191319
13201320 // If there are any constants vectored to BB that TI doesn't handle,
@@ -5177,8 +5177,8 @@ bool SimplifyCFGOpt::simplifyBranchOnICmpChain(BranchInst *BI,
51775177 SwitchInst *New = Builder.CreateSwitch (CompVal, DefaultBB, Values.size ());
51785178
51795179 // Add all of the 'cases' to the switch instruction.
5180- for (unsigned i = 0 , e = Values. size (); i != e; ++i )
5181- New->addCase (Values[i] , EdgeBB);
5180+ for (ConstantInt *Val : Values)
5181+ New->addCase (Val , EdgeBB);
51825182
51835183 // We added edges from PI to the EdgeBB. As such, if there were any
51845184 // PHI nodes in EdgeBB, they need entries to be added corresponding to
@@ -6453,9 +6453,7 @@ SwitchLookupTable::SwitchLookupTable(
64536453
64546454 // Build up the table contents.
64556455 SmallVector<Constant *, 64 > TableContents (TableSize);
6456- for (size_t I = 0 , E = Values.size (); I != E; ++I) {
6457- ConstantInt *CaseVal = Values[I].first ;
6458- Constant *CaseRes = Values[I].second ;
6456+ for (const auto &[CaseVal, CaseRes] : Values) {
64596457 assert (CaseRes->getType () == ValueType);
64606458
64616459 uint64_t Idx = (CaseVal->getValue () - Offset->getValue ()).getLimitedValue ();
0 commit comments