1; 2; There should be just a single copy of loop when strictest mutiplier candidates 3; formula (unscaled candidates == 0) is enforced: 4; 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 8; 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 12; 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 16; 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 20; 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: 25; 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 29; 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 33; 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 37; copies of the loop: 38; 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 42; 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 46; 47; Similarly get 48; 2^(num conds) == 2^5 == 32 49; copies of the loop when cost multiplier is disabled: 50; 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 53; 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 56; 57; Single loop, not unswitched 58; LOOP1: Loop at depth 1 containing: 59; LOOP1-NOT: Loop at depth 1 containing: 60 61; 5 loops, unswitched 4 times 62; LOOP5-COUNT-5: Loop at depth 1 containing: 63; LOOP5-NOT: Loop at depth 1 containing: 64 65; 32 loops, fully unswitched 66; LOOP32-COUNT-32: Loop at depth 1 containing: 67; LOOP32-NOT: Loop at depth 1 containing: 68 69define void @loop_simple5(i32* %addr, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5) { 70entry: 71 br label %loop 72loop: 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 76loop_next1_right: 77 br label %loop_next1 78loop_next1: 79 br i1 %c2, label %loop_next2, label %loop_next2_right 80loop_next2_right: 81 br label %loop_next2 82loop_next2: 83 br i1 %c3, label %loop_next3, label %loop_next3_right 84loop_next3_right: 85 br label %loop_next3 86loop_next3: 87 br i1 %c4, label %loop_next4, label %loop_next4_right 88loop_next4_right: 89 br label %loop_next4 90loop_next4: 91 br i1 %c5, label %loop_latch, label %loop_latch_right 92loop_latch_right: 93 br label %loop_latch 94loop_latch: 95 store volatile i32 0, i32* %addr 96 %test_loop = icmp slt i32 %iv, 50 97 br i1 %test_loop, label %loop, label %exit 98exit: 99 ret void 100} 101