llvm.org GIT mirror llvm / caaecec
[MemorySSA] Update for partial unswitch. Update MSSA for blocks cloned when doing partial unswitching. Enable additional testing with MSSA. Resolves PR43641. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374850 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 1 year, 7 days ago
11 changed file(s) with 135 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
21392139 // the branch in the split block.
21402140 buildPartialUnswitchConditionalBranch(*SplitBB, Invariants, Direction,
21412141 *ClonedPH, *LoopPH);
2142 if (MSSAU) {
2143 // Perform MSSA cloning updates.
2144 for (auto &VMap : VMaps)
2145 MSSAU->updateForClonedLoop(LBRPO, ExitBlocks, *VMap,
2146 /*IgnoreIncomingWithNoClones=*/true);
2147 MSSAU->updateExitBlocksForClonedLoop(ExitBlocks, VMaps, DT);
2148 }
21422149 DTUpdates.push_back({DominatorTree::Insert, SplitBB, ClonedPH});
21432150 }
21442151
0 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -enable-mssa-loop-dependency -verify-memoryssa -S < %s | FileCheck %s
1 ; REQUIRES: asserts
2
3 ; CHECK-LABEL: @c
4 define dso_local void @c(i32 signext %d) local_unnamed_addr {
5 entry:
6 br i1 undef, label %while.end, label %while.body.lr.ph
7
8 while.body.lr.ph: ; preds = %entry
9 %tobool1 = icmp ne i32 %d, 0
10 br label %while.body
11
12 while.body: ; preds = %while.body, %while.body.lr.ph
13 %call = tail call signext i32 bitcast (i32 (...)* @e to i32 ()*)()
14 %0 = and i1 %tobool1, undef
15 br i1 %0, label %while.body, label %while.end
16
17 while.end: ; preds = %while.body, %entry
18 ret void
19 }
20
21 declare signext i32 @e(...) local_unnamed_addr
0 ; RUN: opt < %s -simple-loop-unswitch -enable-nontrivial-unswitch -S 2>&1 | FileCheck %s
11 ; RUN: opt < %s -passes='unswitch' -S 2>&1 | FileCheck %s
2 ; RUN: opt < %s -passes='loop-mssa(unswitch)' -S 2>&1 | FileCheck %s
23 ;
34 ; Checking that (dead) blocks from inner loop are deleted after unswitch.
45 ;
99 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
1010 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1111 ;
12 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
13 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
14 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
15 ;
16 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
17 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
18 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1219 ;
1320 ; When we relax the candidates part of a multiplier formula
1421 ; (unscaled candidates == 4) we start getting some unswitches,
1926 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
2027 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV1
2128 ;
29 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
30 ; RUN: -unswitch-num-initial-unscaled-candidates=4 -unswitch-siblings-toplevel-div=1 \
31 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
32 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV1
33 ;
2234 ; NB: sort -b is essential here and below, otherwise blanks might lead to different
2335 ; order depending on locale.
2436 ;
2739 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
2840 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV2
2941 ;
42 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
43 ; RUN: -unswitch-num-initial-unscaled-candidates=4 -unswitch-siblings-toplevel-div=2 \
44 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
45 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE4-DIV2
3046 ;
3147 ; Get
3248 ; 2^(num conds) == 2^5 = 32
3450 ;
3551 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
3652 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
53 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP32
54 ;
55 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
56 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
3757 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP32
3858 ;
3959 ; Single loop nest, not unswitched
1414 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
1515 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1616 ;
17 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
18 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
19 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1720 ;
21 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
22 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
23 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
24 ;
25 ; When we relax the candidates part of a multiplier formula
1826 ; When we relax the candidates part of a multiplier formula
1927 ; (unscaled candidates == 2) we start getting some unswitches in outer loops,
2028 ; which leads to siblings multiplier kicking in.
2230 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
2331 ; RUN: -unswitch-num-initial-unscaled-candidates=3 -unswitch-siblings-toplevel-div=1 \
2432 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
33 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV1
34 ;
35 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
36 ; RUN: -unswitch-num-initial-unscaled-candidates=3 -unswitch-siblings-toplevel-div=1 \
37 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
2538 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV1
2639 ;
2740 ; NB: sort -b is essential here and below, otherwise blanks might lead to different
3245 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
3346 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV2
3447 ;
48 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
49 ; RUN: -unswitch-num-initial-unscaled-candidates=3 -unswitch-siblings-toplevel-div=2 \
50 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
51 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-UNSCALE3-DIV2
52 ;
3553 ; With disabled cost-multiplier we get maximal possible amount of unswitches.
3654 ;
3755 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
3856 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
57 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
58 ;
59 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
60 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
3961 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
4062 ;
4163 ; Single loop nest, not unswitched
99 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
1010 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1111 ;
12 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
13 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
14 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
15 ;
16 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
17 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
18 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
19 ;
20 ; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
21 ; some unswitches to happen until siblings multiplier starts kicking in:
1222 ; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
1323 ; some unswitches to happen until siblings multiplier starts kicking in:
1424 ;
1525 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
1626 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
1727 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
28 ;
29 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
30 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
31 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP5
1832 ;
1933 ; With relaxed candidates multiplier (unscaled candidates == 8) and with relaxed
2034 ; siblings multiplier for top-level loops (toplevel-div == 8) we should get
2539 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
2640 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
2741 ;
42 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
43 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
44 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
45 ;
2846 ; Similarly get
2947 ; 2^(num conds) == 2^5 == 32
3048 ; copies of the loop when cost multiplier is disabled:
3250 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
3351 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
3452 ;
53 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
54 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP32
3555 ;
3656 ; Single loop, not unswitched
3757 ; LOOP1: Loop at depth 1 containing:
2121 ;
2222 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
2323 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
24 ;
25 ;
26 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
27 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
28 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
29 ;
30 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
31 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=8 \
32 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
33 ;
34 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
35 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
36 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
37 ;
38 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
39 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
40 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
41 ;
42 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
43 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
2444 ;
2545 ;
2646 ; Single loop, not unswitched
1616 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
1717 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1818 ;
19 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
20 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=1 \
21 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
22 ;
23 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
24 ; RUN: -unswitch-num-initial-unscaled-candidates=0 -unswitch-siblings-toplevel-div=16 \
25 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | FileCheck %s --check-prefixes=LOOP1
1926 ;
2027 ; With relaxed candidates multiplier (unscaled candidates == 8) we should allow
2128 ; some unswitches to happen until siblings multiplier starts kicking in:
2330 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
2431 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
2532 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
33 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX
34 ;
35 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
36 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=1 \
37 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
2638 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX
2739 ;
2840 ; With relaxed candidates multiplier (unscaled candidates == 8) and with relaxed
3446 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
3547 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX2
3648 ;
49 ; RUN: opt < %s -enable-unswitch-cost-multiplier=true \
50 ; RUN: -unswitch-num-initial-unscaled-candidates=8 -unswitch-siblings-toplevel-div=8 \
51 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
52 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-RELAX2
53 ;
3754 ; We get hundreds of copies of the loop when cost multiplier is disabled:
3855 ;
3956 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
4057 ; RUN: -passes='loop(unswitch),print' -disable-output 2>&1 | \
4158 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
4259 ;
60 ; RUN: opt < %s -enable-unswitch-cost-multiplier=false \
61 ; RUN: -passes='loop-mssa(unswitch),print' -disable-output 2>&1 | \
62 ; RUN: sort -b -k 1 | FileCheck %s --check-prefixes=LOOP-MAX
4363
4464 ; Single loop nest, not unswitched
4565 ; LOOP1: Loop at depth 1 containing:
0 ; Specifically exercise the cost modeling for non-trivial loop unswitching.
11 ;
22 ; RUN: opt -passes='loop(unswitch),verify' -unswitch-threshold=5 -S < %s | FileCheck %s
3 ; RUN: opt -passes='loop-mssa(unswitch),verify' -unswitch-threshold=5 -S < %s | FileCheck %s
34 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -unswitch-threshold=5 -S < %s | FileCheck %s
45 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -unswitch-threshold=5 -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
56
0 ; REQUIRES: asserts
11 ; RUN: opt -passes='unswitch' -disable-output -S < %s
2 ; RUN: opt -passes='loop-mssa(unswitch)' -disable-output -S < %s
23 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -disable-output -S < %s
34
45 ; This loop shouldn't trigger asserts in SimpleLoopUnswitch.
0 ; RUN: opt -passes='loop(unswitch),verify' -S < %s | FileCheck %s
1 ; RUN: opt -passes='loop-mssa(unswitch),verify' -S < %s | FileCheck %s
12 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -S < %s | FileCheck %s
23 ; RUN: opt -simple-loop-unswitch -enable-nontrivial-unswitch -enable-mssa-loop-dependency=true -verify-memoryssa -S < %s | FileCheck %s
34