74 lines · plain
1; RUN: opt < %s -enable-loop-distribute -passes='loop-distribute,loop-mssa(simple-loop-unswitch<nontrivial>),loop-distribute' -o /dev/null -S -verify-analysis-invalidation=0 -debug-pass-manager=verbose 2>&1 | FileCheck %s2 3 4; Running loop-distribute will result in LoopAccessAnalysis being required and5; cached in the LoopAnalysisManagerFunctionProxy.6;7; CHECK: Running analysis: LoopAccessAnalysis on test68 9 10; Then simple-loop-unswitch is removing/replacing some loops (resulting in11; Loop objects used as key in the analyses cache is destroyed). So here we12; want to see that any analysis results cached on the destroyed loop is13; cleared. A special case here is that loop_a_inner is destroyed when14; unswitching the parent loop.15;16; The bug solved and verified by this test case was related to the17; SimpleLoopUnswitch not marking the Loop as removed, so we missed clearing18; the analysis caches.19;20; CHECK: Running pass: SimpleLoopUnswitchPass on loop %loop_begin in function test621; CHECK-NEXT: Clearing all analysis results for: loop_a_inner22 23 24; When running loop-distribute the second time we can see that loop_a_inner25; 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 the27; loop_a_inner related analysis above.28;29; CHECK: Invalidating analysis: LoopAccessAnalysis on test630; CHECK-NEXT: Running pass: LoopDistributePass on test631; CHECK-NEXT: Running analysis: LoopAccessAnalysis on test632 33 34define i32 @test6(ptr %ptr, i1 %cond1, ptr %a.ptr, ptr %b.ptr) {35entry:36 br label %loop_begin37 38loop_begin:39 %v = load i1, ptr %ptr40 br i1 %cond1, label %loop_a, label %loop_b41 42loop_a:43 br label %loop_a_inner44 45loop_a_inner:46 %va = load i1, ptr %ptr47 %a = load i32, ptr %a.ptr48 br i1 %va, label %loop_a_inner, label %loop_a_inner_exit49 50loop_a_inner_exit:51 %a.lcssa = phi i32 [ %a, %loop_a_inner ]52 br label %latch53 54loop_b:55 br label %loop_b_inner56 57loop_b_inner:58 %vb = load i1, ptr %ptr59 %b = load i32, ptr %b.ptr60 br i1 %vb, label %loop_b_inner, label %loop_b_inner_exit61 62loop_b_inner_exit:63 %b.lcssa = phi i32 [ %b, %loop_b_inner ]64 br label %latch65 66latch:67 %ab.phi = phi i32 [ %a.lcssa, %loop_a_inner_exit ], [ %b.lcssa, %loop_b_inner_exit ]68 br i1 %v, label %loop_begin, label %loop_exit69 70loop_exit:71 %ab.lcssa = phi i32 [ %ab.phi, %latch ]72 ret i32 %ab.lcssa73}74