1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

SimplifyCFG: Range'ify some for-loops. No functional change.

llvm-svn: 222215
This commit is contained in:
Hans Wennborg 2014-11-18 02:37:11 +00:00
parent 35be2aba4c
commit aaf76f8d38

View File

@ -3893,9 +3893,8 @@ static bool ShouldBuildLookupTable(SwitchInst *SI,
bool AllTablesFitInRegister = true; bool AllTablesFitInRegister = true;
bool HasIllegalType = false; bool HasIllegalType = false;
for (SmallDenseMap<PHINode*, Type*>::const_iterator I = ResultTypes.begin(), for (const auto &I : ResultTypes) {
E = ResultTypes.end(); I != E; ++I) { Type *Ty = I.second;
Type *Ty = I->second;
// Saturate this flag to true. // Saturate this flag to true.
HasIllegalType = HasIllegalType || !TTI.isTypeLegal(Ty); HasIllegalType = HasIllegalType || !TTI.isTypeLegal(Ty);
@ -3979,16 +3978,17 @@ static bool SwitchToLookupTable(SwitchInst *SI,
return false; return false;
// Append the result from this case to the list for each phi. // Append the result from this case to the list for each phi.
for (ResultsTy::iterator I = Results.begin(), E = Results.end(); I!=E; ++I) { for (const auto &I : Results) {
if (!ResultLists.count(I->first)) PHINode *PHI = I.first;
PHIs.push_back(I->first); Constant *Value = I.second;
ResultLists[I->first].push_back(std::make_pair(CaseVal, I->second)); if (!ResultLists.count(PHI))
PHIs.push_back(PHI);
ResultLists[PHI].push_back(std::make_pair(CaseVal, Value));
} }
} }
// Keep track of the result types. // Keep track of the result types.
for (size_t I = 0, E = PHIs.size(); I != E; ++I) { for (PHINode *PHI : PHIs) {
PHINode *PHI = PHIs[I];
ResultTypes[PHI] = ResultLists[PHI][0].second->getType(); ResultTypes[PHI] = ResultLists[PHI][0].second->getType();
} }
@ -4005,6 +4005,7 @@ static bool SwitchToLookupTable(SwitchInst *SI,
HasDefaultResults = GetCaseResults(SI, nullptr, SI->getDefaultDest(), HasDefaultResults = GetCaseResults(SI, nullptr, SI->getDefaultDest(),
&CommonDest, DefaultResultsList, DL); &CommonDest, DefaultResultsList, DL);
} }
bool NeedMask = (TableHasHoles && !HasDefaultResults); bool NeedMask = (TableHasHoles && !HasDefaultResults);
if (NeedMask) { if (NeedMask) {
// As an extra penalty for the validity test we require more cases. // As an extra penalty for the validity test we require more cases.
@ -4014,9 +4015,9 @@ static bool SwitchToLookupTable(SwitchInst *SI,
return false; return false;
} }
for (size_t I = 0, E = DefaultResultsList.size(); I != E; ++I) { for (const auto &I : DefaultResultsList) {
PHINode *PHI = DefaultResultsList[I].first; PHINode *PHI = I.first;
Constant *Result = DefaultResultsList[I].second; Constant *Result = I.second;
DefaultResults[PHI] = Result; DefaultResults[PHI] = Result;
} }