• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -simplifycfg -S | \
2; RUN:   grep switch | count 1
3
4; Test that a switch going to a switch on the same value can be merged.   All
5; three switches in this example can be merged into one big one.
6
7declare void @foo1()
8
9declare void @foo2()
10
11declare void @foo3()
12
13declare void @foo4()
14
15define void @test1(i32 %V) {
16        switch i32 %V, label %F [
17                 i32 4, label %T
18                 i32 17, label %T
19                 i32 5, label %T
20                 i32 1234, label %F
21        ]
22T:              ; preds = %0, %0, %0
23        switch i32 %V, label %F [
24                 i32 4, label %A
25                 i32 17, label %B
26                 i32 42, label %C
27        ]
28A:              ; preds = %T
29        call void @foo1( )
30        ret void
31B:              ; preds = %F, %F, %T
32        call void @foo2( )
33        ret void
34C:              ; preds = %T
35        call void @foo3( )
36        ret void
37F:              ; preds = %F, %T, %0, %0
38        switch i32 %V, label %F [
39                 i32 4, label %B
40                 i32 18, label %B
41                 i32 42, label %D
42        ]
43D:              ; preds = %F
44        call void @foo4( )
45        ret void
46}
47
48