2008-03-18 03:45:45 +00:00
|
|
|
; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | \
|
2007-08-15 13:36:28 +00:00
|
|
|
; RUN: grep switch | count 1
|
2004-02-24 07:21:09 +00:00
|
|
|
|
|
|
|
; 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.
|
|
|
|
|
2008-03-18 03:45:45 +00:00
|
|
|
declare void @foo1()
|
2004-02-24 07:21:09 +00:00
|
|
|
|
2008-03-18 03:45:45 +00:00
|
|
|
declare void @foo2()
|
|
|
|
|
|
|
|
declare void @foo3()
|
2004-02-24 07:21:09 +00:00
|
|
|
|
2008-03-18 03:45:45 +00:00
|
|
|
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
|
2004-02-24 07:21:09 +00:00
|
|
|
]
|
2008-03-18 03:45:45 +00:00
|
|
|
A: ; preds = %T
|
|
|
|
call void @foo1( )
|
2004-02-24 07:21:09 +00:00
|
|
|
ret void
|
2008-03-18 03:45:45 +00:00
|
|
|
B: ; preds = %F, %F, %T
|
|
|
|
call void @foo2( )
|
2004-02-24 07:21:09 +00:00
|
|
|
ret void
|
2008-03-18 03:45:45 +00:00
|
|
|
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
|
2004-02-24 07:21:09 +00:00
|
|
|
]
|
2008-03-18 03:45:45 +00:00
|
|
|
D: ; preds = %F
|
|
|
|
call void @foo4( )
|
2004-02-24 07:21:09 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|