1; RUN: opt < %s -S -passes="default<O1>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
2; RUN: opt < %s -S -passes="default<O2>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
3; RUN: opt < %s -S -passes="default<O3>" | FileCheck %s -check-prefixes=NONTRIVIAL,CHECK
4; RUN: opt < %s -S -passes="default<O3>" -enable-npm-O3-nontrivial-unswitch=0 | FileCheck %s -check-prefixes=TRIVIAL,CHECK
5; RUN: opt < %s -S -passes="default<Os>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
6; RUN: opt < %s -S -passes="default<Oz>" | FileCheck %s -check-prefixes=TRIVIAL,CHECK
7
8declare i32 @a()
9declare i32 @b()
10declare i32 @c()
11
12; TRIVIAL-NOT: loop_begin.us:
13; NONTRIVIAL: loop_begin.us:
14
15define i32 @test1(i1* %ptr, i1 %cond1, i1 %cond2) {
16entry:
17  br label %loop_begin
18
19loop_begin:
20  br i1 %cond1, label %loop_a, label %loop_b
21
22loop_a:
23  call i32 @a()
24  br label %latch
25
26loop_b:
27  br i1 %cond2, label %loop_b_a, label %loop_b_b
28
29loop_b_a:
30  call i32 @b()
31  br label %latch
32
33loop_b_b:
34  call i32 @c()
35  br label %latch
36
37latch:
38  %v = load i1, i1* %ptr
39  br i1 %v, label %loop_begin, label %loop_exit
40
41loop_exit:
42  ret i32 0
43}
44
45; CHECK-NOT: loop2_begin.us:
46define i32 @test2(i1* %ptr, i1 %cond1, i1 %cond2) optsize {
47entry:
48  br label %loop2_begin
49
50loop2_begin:
51  br i1 %cond1, label %loop2_a, label %loop2_b
52
53loop2_a:
54  call i32 @a()
55  br label %latch2
56
57loop2_b:
58  br i1 %cond2, label %loop2_b_a, label %loop2_b_b
59
60loop2_b_a:
61  call i32 @b()
62  br label %latch2
63
64loop2_b_b:
65  call i32 @c()
66  br label %latch2
67
68latch2:
69  %v = load i1, i1* %ptr
70  br i1 %v, label %loop2_begin, label %loop2_exit
71
72loop2_exit:
73  ret i32 0
74}
75