@@ -976,8 +976,8 @@ bool SimplifyCFGOpt::simplifyEqualityComparisonWithOnlyPredecessor(
976
976
SwitchInstProfUpdateWrapper SI = *cast<SwitchInst>(TI);
977
977
// Okay, TI has cases that are statically dead, prune them away.
978
978
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 );
981
981
982
982
LLVM_DEBUG (dbgs () << " Threading pred instr: " << *Pred->getTerminator ()
983
983
<< " Through successor TI: " << *TI);
@@ -1307,14 +1307,14 @@ bool SimplifyCFGOpt::performValueComparisonIntoPredecessorFolding(
1307
1307
1308
1308
// Okay, now we know which constants were sent to BB from the
1309
1309
// 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 )) {
1312
1312
// If this is one we are capable of getting...
1313
1313
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
1318
1318
}
1319
1319
1320
1320
// If there are any constants vectored to BB that TI doesn't handle,
@@ -5177,8 +5177,8 @@ bool SimplifyCFGOpt::simplifyBranchOnICmpChain(BranchInst *BI,
5177
5177
SwitchInst *New = Builder.CreateSwitch (CompVal, DefaultBB, Values.size ());
5178
5178
5179
5179
// 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);
5182
5182
5183
5183
// We added edges from PI to the EdgeBB. As such, if there were any
5184
5184
// PHI nodes in EdgeBB, they need entries to be added corresponding to
@@ -6453,9 +6453,7 @@ SwitchLookupTable::SwitchLookupTable(
6453
6453
6454
6454
// Build up the table contents.
6455
6455
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) {
6459
6457
assert (CaseRes->getType () == ValueType);
6460
6458
6461
6459
uint64_t Idx = (CaseVal->getValue () - Offset->getValue ()).getLimitedValue ();
0 commit comments