2 ; There should be just a single copy of loop when strictest mutiplier candidates
3 ; formula (unscaled candidates == 0) is enforced:
5 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
6 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
7 ; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
9 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
10 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
11 ; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
13 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
14 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
15 ; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
17 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
18 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
19 ; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
21 ; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
22 ; some unswitches to happen until siblings multiplier starts kicking in:
23 ; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
24 ; some unswitches to happen until siblings multiplier starts kicking in:
26 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
27 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
28 ; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
30 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
31 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
32 ; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
34 ; With relaxed candidates multiplier (unscaled candidates == 8) and with relaxed
35 ; siblings multiplier for top-level loops (toplevel-div == 8) we should get
36 ; 2^(num conds) == 2^5 == 32
39 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
40 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
41 ; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
43 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
44 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
45 ; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
48 ; 2^(num conds) == 2^5 == 32
49 ; copies of the loop when cost multiplier is disabled:
51 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
52 ; RUN: -passes='loop(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
54 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
55 ; RUN: -passes='loop-mssa(unswitch<nontrivial>),print<loops>' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
57 ; Single loop, not unswitched
58 ; LOOP1: Loop at depth 1 containing:
59 ; LOOP1-NOT: Loop at depth 1 containing:
61 ; 5 loops, unswitched 4 times
62 ; LOOP5-COUNT-5: Loop at depth 1 containing:
63 ; LOOP5-NOT: Loop at depth 1 containing:
65 ; 32 loops, fully unswitched
66 ; LOOP32-COUNT-32: Loop at depth 1 containing:
67 ; LOOP32-NOT: Loop at depth 1 containing:
69 define void @loop_simple5(i32* %addr, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5) {
73 %iv = phi i32 [0, %entry], [%iv.next, %loop_latch]
74 %iv.next = add i32 %iv, 1
75 br i1 %c1, label %loop_next1, label %loop_next1_right
79 br i1 %c2, label %loop_next2, label %loop_next2_right
83 br i1 %c3, label %loop_next3, label %loop_next3_right
87 br i1 %c4, label %loop_next4, label %loop_next4_right
91 br i1 %c5, label %loop_latch, label %loop_latch_right
95 store volatile i32 0, i32* %addr
96 %test_loop = icmp slt i32 %iv, 50
97 br i1 %test_loop, label %loop, label %exit