Home | History | Annotate | Download | only in SimplifyCFG
      1 ; RUN: opt < %s -simplifycfg -S | FileCheck %s
      2 
      3 define void @test1(i1 %C, i1* %BP) {
      4 ; CHECK: @test1
      5 ; CHECK: entry:
      6 ; CHECK-NEXT: ret void
      7 entry:
      8         br i1 %C, label %T, label %F
      9 T:
     10         store i1 %C, i1* %BP
     11         unreachable
     12 F:
     13         ret void
     14 }
     15 
     16 define void @test2() {
     17 ; CHECK: @test2
     18 ; CHECK: entry:
     19 ; CHECK-NEXT: call void @test2()
     20 ; CHECK-NEXT: ret void
     21 entry:
     22         invoke void @test2( )
     23                         to label %N unwind label %U
     24 U:
     25         unreachable
     26 N:
     27         ret void
     28 }
     29 
     30 define i32 @test3(i32 %v) {
     31 ; CHECK: @test3
     32 ; CHECK: entry:
     33 ; CHECK-NEXT: [[CMP:%[A-Za-z0-9]+]] = icmp eq i32 %v, 2
     34 ; CHECK-NEXT: select i1 [[CMP]], i32 2, i32 1
     35 ; CHECK-NEXT: ret
     36 entry:
     37         switch i32 %v, label %default [
     38                  i32 1, label %U
     39                  i32 2, label %T
     40         ]
     41 default:
     42         ret i32 1
     43 U:
     44         unreachable
     45 T:
     46         ret i32 2
     47 }
     48 
     49 ; PR9450
     50 define i32 @test4(i32 %v) {
     51 ; CHECK: entry:
     52 ; CHECK-NEXT:  switch i32 %v, label %T [
     53 ; CHECK-NEXT:    i32 3, label %V
     54 ; CHECK-NEXT:    i32 2, label %U
     55 ; CHECK-NEXT:  ]
     56 
     57 entry:
     58         br label %SWITCH
     59 V:
     60         ret i32 7
     61 SWITCH:
     62         switch i32 %v, label %default [
     63                  i32 1, label %T
     64                  i32 2, label %U
     65                  i32 3, label %V
     66         ]
     67 default:
     68         unreachable
     69 U:
     70         ret i32 1
     71 T:
     72         ret i32 2
     73 }
     74