Fix switch_to_lookup_table.ll test from r163302.

The lookup tables did not get built in a deterministic order.
This makes them get built in the order that the corresponding phi nodes
were found.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163305 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hans Wennborg
2012-09-06 10:10:35 +00:00
parent ba8562af44
commit 3bd51b8df3
2 changed files with 12 additions and 11 deletions

View File

@ -3190,13 +3190,14 @@ static bool SwitchToLookupTable(SwitchInst *SI,
SmallDenseMap<PHINode*, Constant*> SingleResults;
Module &Mod = *CommonDest->getParent()->getParent();
for (SmallDenseMap<PHINode*, ResultListTy>::iterator I = ResultLists.begin(),
E = ResultLists.end(); I != E; ++I) {
PHINode *PHI = I->first;
for (SmallVector<PHINode*, 4>::iterator I = PHIs.begin(), E = PHIs.end();
I != E; ++I) {
PHINode *PHI = *I;
Constant *SingleResult = NULL;
LookupTables[PHI] = BuildLookupTable(Mod, TableSize, MinCaseVal, I->second,
DefaultResults[PHI], &SingleResult);
LookupTables[PHI] = BuildLookupTable(Mod, TableSize, MinCaseVal,
ResultLists[PHI], DefaultResults[PHI],
&SingleResult);
SingleResults[PHI] = SingleResult;
}