Home | History | Annotate | Download | only in SimplifyCFG
      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 
      7 declare void @foo1()
      8 
      9 declare void @foo2()
     10 
     11 declare void @foo3()
     12 
     13 declare void @foo4()
     14 
     15 define 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         ]
     22 T:              ; 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         ]
     28 A:              ; preds = %T
     29         call void @foo1( )
     30         ret void
     31 B:              ; preds = %F, %F, %T
     32         call void @foo2( )
     33         ret void
     34 C:              ; preds = %T
     35         call void @foo3( )
     36         ret void
     37 F:              ; 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         ]
     43 D:              ; preds = %F
     44         call void @foo4( )
     45         ret void
     46 }
     47 
     48