1;
2; Here all the branches are exiting ones. Checking that we dont have
3; exponential behavior with any kind of controlling heuristics here.
4;
5; There we should have just a single loop.
6;
7; RUN: opt < %s -enable-nontrivial-unswitch -enable-unswitch-cost-multiplier=true \
8; RUN:     -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
9; RUN:     -passes='loop(unswitch),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
10;
11; RUN: opt < %s -enable-nontrivial-unswitch -enable-unswitch-cost-multiplier=true \
12; RUN:     -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
13; RUN:     -passes='loop(unswitch),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
14;
15; RUN: opt < %s -enable-nontrivial-unswitch -enable-unswitch-cost-multiplier=true \
16; RUN:     -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
17; RUN:     -passes='loop(unswitch),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
18;
19; RUN: opt < %s -enable-nontrivial-unswitch -enable-unswitch-cost-multiplier=true \
20; RUN:     -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
21; RUN:     -passes='loop(unswitch),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
22;
23; RUN: opt < %s -enable-nontrivial-unswitch -enable-unswitch-cost-multiplier=false \
24; RUN:     -passes='loop(unswitch),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
25;
26;
27; Single loop, not unswitched
28; LOOP1:     Loop at depth 1 containing:
29; LOOP1-NOT: Loop at depth 1 containing:
30
31declare void @bar()
32
33define void @loop_simple5(i32* %addr, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5) {
34entry:
35  br label %loop
36loop:
37  %iv = phi i32 [0, %entry], [%iv.next, %loop_latch]
38  %iv.next = add i32 %iv, 1
39  ;; disabling trivial unswitch
40  call void @bar()
41  br i1 %c1, label %loop_next1, label %exit
42loop_next1:
43  br i1 %c2, label %loop_next2, label %exit
44loop_next2:
45  br i1 %c3, label %loop_next3, label %exit
46loop_next3:
47  br i1 %c4, label %loop_next4, label %exit
48loop_next4:
49  br i1 %c5, label %loop_latch, label %exit
50loop_latch:
51  store volatile i32 0, i32* %addr
52  %test_loop = icmp slt i32 %iv, 50
53  br i1 %test_loop, label %loop, label %exit
54exit:
55  ret void
56}
57