summaryrefslogtreecommitdiffstats
path: root/test/Transforms/SimplifyCFG/switch_switch_fold.ll
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2010-02-10 11:10:31 -0800
committerShih-wei Liao <sliao@google.com>2010-02-10 11:10:31 -0800
commite264f62ca09a8f65c87a46d562a4d0f9ec5d457e (patch)
tree59e3d57ef656cef79afa708ae0a3daf25cd91fcf /test/Transforms/SimplifyCFG/switch_switch_fold.ll
downloadexternal_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.zip
external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.gz
external_llvm-e264f62ca09a8f65c87a46d562a4d0f9ec5d457e.tar.bz2
Check in LLVM r95781.
Diffstat (limited to 'test/Transforms/SimplifyCFG/switch_switch_fold.ll')
-rw-r--r--test/Transforms/SimplifyCFG/switch_switch_fold.ll47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/switch_switch_fold.ll b/test/Transforms/SimplifyCFG/switch_switch_fold.ll
new file mode 100644
index 0000000..2e2e310
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_switch_fold.ll
@@ -0,0 +1,47 @@
+; RUN: opt < %s -simplifycfg -S | \
+; RUN: grep switch | count 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()
+
+define void @test1(i32 %V) {
+ switch i32 %V, label %F [
+ i32 4, label %T
+ i32 17, label %T
+ i32 5, label %T
+ i32 1234, label %F
+ ]
+T: ; preds = %0, %0, %0
+ switch i32 %V, label %F [
+ i32 4, label %A
+ i32 17, label %B
+ i32 42, label %C
+ ]
+A: ; preds = %T
+ call void @foo1( )
+ ret void
+B: ; preds = %F, %F, %T
+ call void @foo2( )
+ ret void
+C: ; preds = %T
+ call void @foo3( )
+ ret void
+F: ; preds = %F, %T, %0, %0
+ switch i32 %V, label %F [
+ i32 4, label %B
+ i32 18, label %B
+ i32 42, label %D
+ ]
+D: ; preds = %F
+ call void @foo4( )
+ ret void
+}
+