[llvm-commits] [parallel] CVS: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll UncondBranchToReturn.ll switch_create.ll switch_formation.ll switch_switch_fold.ll
Misha Brukman
brukman at cs.uiuc.edu
Mon Mar 1 20:52:56 PST 2004
Changes in directory llvm/test/Regression/Transforms/SimplifyCFG:
PhiEliminate.ll added (r1.1.2.1)
UncondBranchToReturn.ll added (r1.1.2.1)
switch_create.ll added (r1.1.2.1)
switch_formation.ll added (r1.1.2.1)
switch_switch_fold.ll added (r1.1.2.1)
---
Log message:
Merge from trunk
---
Diffs of the changes: (+182 -0)
Index: llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll
diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll:1.1.2.1
*** /dev/null Mon Mar 1 17:59:24 2004
--- llvm/test/Regression/Transforms/SimplifyCFG/PhiEliminate.ll Mon Mar 1 17:59:14 2004
***************
*** 0 ****
--- 1,35 ----
+ ; Test a bunch of cases where the cfg simplification code should
+ ; be able to fold PHI nodes into computation in common cases. Folding the PHI
+ ; nodes away allows the branches to be eliminated, performing a simple form of
+ ; 'if conversion'.
+
+ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis > Output/%s.xform
+ ; RUN: not grep phi Output/%s.xform && grep ret Output/%s.xform
+
+ declare void %use(bool)
+ declare void %use(int)
+
+ void %test(bool %c, int %V) {
+ br bool %c, label %T, label %F
+ T:
+ br label %F
+ F:
+ %B1 = phi bool [true, %0], [false, %T]
+ %B2 = phi bool [true, %T], [false, %0]
+ %I1 = phi int [1, %T], [0, %0]
+ %I2 = phi int [1, %0], [0, %T]
+ %I3 = phi int [17, %T], [0, %0]
+ %I4 = phi int [17, %T], [5, %0]
+ %I5 = phi int [%V, %T], [0, %0]
+ %I6 = phi int [%V, %0], [0, %T]
+ call void %use(bool %B1)
+ call void %use(bool %B2)
+ call void %use(int %I1)
+ call void %use(int %I2)
+ call void %use(int %I3)
+ call void %use(int %I4)
+ call void %use(int %I5)
+ call void %use(int %I6)
+ ret void
+ }
+
Index: llvm/test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll
diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll:1.1.2.1
*** /dev/null Mon Mar 1 17:59:24 2004
--- llvm/test/Regression/Transforms/SimplifyCFG/UncondBranchToReturn.ll Mon Mar 1 17:59:14 2004
***************
*** 0 ****
--- 1,32 ----
+ ; The unify-function-exit-nodes pass often makes basic blocks that just contain
+ ; a PHI node and a return. Make sure the simplify cfg can straighten out this
+ ; important case. This is basically the most trivial form of tail-duplication.
+
+ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep 'br label'
+
+ int %test(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+ T:
+ br label %ret
+ F:
+ br label %ret
+ ret:
+ %X = phi int [%A, %F], [%B, %T]
+ ret int %X
+ }
+
+ ; Make sure it's willing to move unconditional branches to return instructions
+ ; as well, even if the return block is shared and the source blocks are
+ ; non-empty.
+ int %test2(bool %B, int %A, int %B) {
+ br bool %B, label %T, label %F
+ T:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+ F:
+ call int %test(bool true, int 5, int 8)
+ br label %ret
+ ret:
+ ret int %A
+ }
+
Index: llvm/test/Regression/Transforms/SimplifyCFG/switch_create.ll
diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/switch_create.ll:1.1.2.1
*** /dev/null Mon Mar 1 17:59:24 2004
--- llvm/test/Regression/Transforms/SimplifyCFG/switch_create.ll Mon Mar 1 17:59:14 2004
***************
*** 0 ****
--- 1,33 ----
+ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep br
+
+ declare void %foo1()
+ declare void %foo2()
+
+ void %test1(uint %V) {
+ %C1 = seteq uint %V, 4
+ %C2 = seteq uint %V, 17
+ %CN = or bool %C1, %C2
+ br bool %CN, label %T, label %F
+ T:
+ call void %foo1()
+ ret void
+ F:
+ call void %foo2()
+ ret void
+ }
+
+
+ void %test2(int %V) {
+ %C1 = setne int %V, 4
+ %C2 = setne int %V, 17
+ %CN = and bool %C1, %C2
+ br bool %CN, label %T, label %F
+ T:
+ call void %foo1()
+ ret void
+ F:
+ call void %foo2()
+ ret void
+ }
+
+
Index: llvm/test/Regression/Transforms/SimplifyCFG/switch_formation.ll
diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/switch_formation.ll:1.1.2.1
*** /dev/null Mon Mar 1 17:59:24 2004
--- llvm/test/Regression/Transforms/SimplifyCFG/switch_formation.ll Mon Mar 1 17:59:14 2004
***************
*** 0 ****
--- 1,36 ----
+ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | not grep 'br'
+
+ bool %_ZN4llvm11SetCondInst7classofEPKNS_11InstructionE({uint, uint}* %I) {
+ entry:
+ %tmp.1.i = getelementptr {uint, uint}* %I, long 0, ubyte 1
+ %tmp.2.i = load uint* %tmp.1.i
+ %tmp.2 = seteq uint %tmp.2.i, 14
+ br bool %tmp.2, label %shortcirc_done.4, label %shortcirc_next.0
+
+ shortcirc_next.0: ; preds = %entry
+ %tmp.6 = seteq uint %tmp.2.i, 15 ; <bool> [#uses=1]
+ br bool %tmp.6, label %shortcirc_done.4, label %shortcirc_next.1
+
+ shortcirc_next.1: ; preds = %shortcirc_next.0
+ %tmp.11 = seteq uint %tmp.2.i, 16 ; <bool> [#uses=1]
+ br bool %tmp.11, label %shortcirc_done.4, label %shortcirc_next.2
+
+ shortcirc_next.2: ; preds = %shortcirc_next.1
+ %tmp.16 = seteq uint %tmp.2.i, 17 ; <bool> [#uses=1]
+ br bool %tmp.16, label %shortcirc_done.4, label %shortcirc_next.3
+
+ shortcirc_next.3: ; preds = %shortcirc_next.2
+ %tmp.21 = seteq uint %tmp.2.i, 18 ; <bool> [#uses=1]
+ br bool %tmp.21, label %shortcirc_done.4, label %shortcirc_next.4
+
+ shortcirc_next.4: ; preds = %shortcirc_next.3
+ %tmp.26 = seteq uint %tmp.2.i, 19 ; <bool> [#uses=1]
+ br label %UnifiedReturnBlock
+
+ shortcirc_done.4: ; preds = %entry, %shortcirc_next.0, %shortcirc_next.1, %shortcirc_next.2, %shortcirc_next.3
+ br label %UnifiedReturnBlock
+
+ UnifiedReturnBlock: ; preds = %shortcirc_next.4, %shortcirc_done.4
+ %UnifiedRetVal = phi bool [ %tmp.26, %shortcirc_next.4 ], [ true, %shortcirc_done.4 ] ; <bool> [#uses=1]
+ ret bool %UnifiedRetVal
+ }
Index: llvm/test/Regression/Transforms/SimplifyCFG/switch_switch_fold.ll
diff -c /dev/null llvm/test/Regression/Transforms/SimplifyCFG/switch_switch_fold.ll:1.1.2.1
*** /dev/null Mon Mar 1 17:59:24 2004
--- llvm/test/Regression/Transforms/SimplifyCFG/switch_switch_fold.ll Mon Mar 1 17:59:14 2004
***************
*** 0 ****
--- 1,46 ----
+ ; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | grep switch | wc -l | grep 1
+
+ ; Test that a switch going to a switch on the same value can be merged. All
+ ; three switches in this example can be merged into one big one.
+
+ declare void %foo1()
+ declare void %foo2()
+ declare void %foo3()
+ declare void %foo4()
+
+ void %test1(uint %V) {
+ switch uint %V, label %F [
+ uint 4, label %T
+ uint 17, label %T
+ uint 5, label %T
+ uint 1234, label %F
+ ]
+
+ T:
+ switch uint %V, label %F [
+ uint 4, label %A
+ uint 17, label %B
+ uint 42, label %C
+ ]
+ A:
+ call void %foo1()
+ ret void
+
+ B:
+ call void %foo2()
+ ret void
+ C:
+ call void %foo3()
+ ret void
+
+ F:
+ switch uint %V, label %F [
+ uint 4, label %B
+ uint 18, label %B
+ uint 42, label %D
+ ]
+ D:
+ call void %foo4()
+ ret void
+ }
+
More information about the llvm-commits
mailing list