1; RUN: opt < %s -simplifycfg -S | FileCheck %s
2
3define void @test1(i1 %C, i1* %BP) {
4; CHECK: @test1
5; CHECK: entry:
6; CHECK-NEXT: ret void
7entry:
8        br i1 %C, label %T, label %F
9T:
10        store i1 %C, i1* %BP
11        unreachable
12F:
13        ret void
14}
15
16define void @test2() {
17; CHECK: @test2
18; CHECK: entry:
19; CHECK-NEXT: call void @test2()
20; CHECK-NEXT: ret void
21entry:
22        invoke void @test2( )
23                        to label %N unwind label %U
24U:
25        unreachable
26N:
27        ret void
28}
29
30define 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
36entry:
37        switch i32 %v, label %default [
38                 i32 1, label %U
39                 i32 2, label %T
40        ]
41default:
42        ret i32 1
43U:
44        unreachable
45T:
46        ret i32 2
47}
48
49; PR9450
50define 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
57entry:
58        br label %SWITCH
59V:
60        ret i32 7
61SWITCH:
62        switch i32 %v, label %default [
63                 i32 1, label %T
64                 i32 2, label %U
65                 i32 3, label %V
66        ]
67default:
68        unreachable
69U:
70        ret i32 1
71T:
72        ret i32 2
73}
74