1 ; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch<nontrivial>),loop-distribute' -o /dev/null -S -debug-pass-manager=verbose 2>&1 | FileCheck %s
4 ; Running loop-distribute will result in LoopAccessAnalysis being required and
5 ; cached in the LoopAnalysisManagerFunctionProxy.
7 ; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %loop_a_inner<header><latch><exiting>
10 ; Then simple-loop-unswitch is removing/replacing some loops (resulting in
11 ; Loop objects used as key in the analyses cache is destroyed). So here we
12 ; want to see that any analysis results cached on the destroyed loop is
13 ; cleared. A special case here is that loop_a_inner is destroyed when
14 ; unswitching the parent loop.
16 ; The bug solved and verified by this test case was related to the
17 ; SimpleLoopUnswitch not marking the Loop as removed, so we missed clearing
18 ; the analysis caches.
20 ; CHECK: Running pass: SimpleLoopUnswitchPass on Loop at depth 1 containing: %loop_begin<header>,%loop_b,%loop_b_inner,%loop_b_inner_exit,%loop_a,%loop_a_inner,%loop_a_inner_exit,%latch<latch><exiting>
21 ; CHECK-NEXT: Clearing all analysis results for: loop_a_inner
24 ; When running loop-distribute the second time we can see that loop_a_inner
25 ; isn't analysed because the loop no longer exists (instead we find a new loop,
26 ; loop_a_inner.us). This kind of verifies that it was correct to remove the
27 ; loop_a_inner related analysis above.
29 ; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %loop_a_inner.us<header><latch><exiting>
32 define i32 @test6(i1* %ptr, i1 %cond1, i32* %a.ptr, i32* %b.ptr) {
37 %v = load i1, i1* %ptr
38 br i1 %cond1, label %loop_a, label %loop_b
41 br label %loop_a_inner
44 %va = load i1, i1* %ptr
45 %a = load i32, i32* %a.ptr
46 br i1 %va, label %loop_a_inner, label %loop_a_inner_exit
49 %a.lcssa = phi i32 [ %a, %loop_a_inner ]
53 br label %loop_b_inner
56 %vb = load i1, i1* %ptr
57 %b = load i32, i32* %b.ptr
58 br i1 %vb, label %loop_b_inner, label %loop_b_inner_exit
61 %b.lcssa = phi i32 [ %b, %loop_b_inner ]
65 %ab.phi = phi i32 [ %a.lcssa, %loop_a_inner_exit ], [ %b.lcssa, %loop_b_inner_exit ]
66 br i1 %v, label %loop_begin, label %loop_exit
69 %ab.lcssa = phi i32 [ %ab.phi, %latch ]