[llvm-commits] [llvm] r163305 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
Hans Wennborg
hans at hanshq.net
Thu Sep 6 03:10:35 PDT 2012
Author: hans
Date: Thu Sep 6 05:10:35 2012
New Revision: 163305
URL: http://llvm.org/viewvc/llvm-project?rev=163305&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=163305&r1=163304&r2=163305&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Sep 6 05:10:35 2012
@@ -3190,13 +3190,14 @@
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;
}
Modified: llvm/trunk/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll?rev=163305&r1=163304&r2=163305&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll Thu Sep 6 05:10:35 2012
@@ -6,11 +6,11 @@
; The table for @f
; CHECK: @switch.table = private unnamed_addr constant [7 x i32] [i32 55, i32 123, i32 0, i32 -1, i32 27, i32 62, i32 1]
-; The float table for @h
-; CHECK: @switch.table1 = private unnamed_addr constant [4 x float] [float 0x40091EB860000000, float 0x3FF3BE76C0000000, float 0x4012449BA0000000, float 0x4001AE1480000000]
-
; The int table for @h
-; CHECK: @switch.table2 = private unnamed_addr constant [4 x i8] c"*\09X\05"
+; CHECK: @switch.table1 = private unnamed_addr constant [4 x i8] c"*\09X\05"
+
+; The float table for @h
+; CHECK: @switch.table2 = private unnamed_addr constant [4 x float] [float 0x40091EB860000000, float 0x3FF3BE76C0000000, float 0x4012449BA0000000, float 0x4001AE1480000000]
; The table for @foostring
; CHECK: @switch.table3 = private unnamed_addr constant [4 x i8*] [i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8]* @.str3, i64 0, i64 0)]
@@ -85,9 +85,9 @@
; CHECK-NEXT: %0 = icmp ult i32 %switch.tableidx, 4
; CHECK-NEXT: br i1 %0, label %switch.lookup, label %sw.epilog
; CHECK: switch.lookup:
-; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i8]* @switch.table2, i32 0, i32 %switch.tableidx
+; CHECK-NEXT: %switch.gep = getelementptr inbounds [4 x i8]* @switch.table1, i32 0, i32 %switch.tableidx
; CHECK-NEXT: %switch.load = load i8* %switch.gep
-; CHECK-NEXT: %switch.gep1 = getelementptr inbounds [4 x float]* @switch.table1, i32 0, i32 %switch.tableidx
+; CHECK-NEXT: %switch.gep1 = getelementptr inbounds [4 x float]* @switch.table2, i32 0, i32 %switch.tableidx
; CHECK-NEXT: %switch.load2 = load float* %switch.gep1
; CHECK-NEXT: br label %sw.epilog
; CHECK: sw.epilog:
More information about the llvm-commits
mailing list