Chandler Carruth | 7c888dc | 2017-08-08 02:24:20 +0000 | [diff] [blame] | 1 | ; This test exercises that we don't corrupt a loop-analysis when running loop |
| 2 | ; unrolling in a way that deletes a loop. To do that, we first ensure the |
| 3 | ; analysis is cached, then unroll the loop (deleting it) and make sure that the |
| 4 | ; next function doesn't get a cache "hit" for this stale analysis result. |
| 5 | ; |
| 6 | ; RUN: opt -S -passes='loop(require<access-info>),unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s |
| 7 | ; |
| 8 | ; CHECK: Starting llvm::Function pass manager run. |
| 9 | ; CHECK: Running pass: FunctionToLoopPassAdaptor |
| 10 | ; CHECK: Running analysis: LoopAnalysis |
Chandler Carruth | e32ebca | 2017-08-08 02:27:49 +0000 | [diff] [blame] | 11 | ; CHECK: Running analysis: InnerAnalysisManagerProxy< |
Chandler Carruth | 7c888dc | 2017-08-08 02:24:20 +0000 | [diff] [blame] | 12 | ; CHECK: Starting Loop pass manager run. |
| 13 | ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis |
| 14 | ; CHECK: Running analysis: LoopAccessAnalysis on inner1.header |
| 15 | ; CHECK: Finished Loop pass manager run. |
| 16 | ; CHECK: Starting Loop pass manager run. |
| 17 | ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis |
| 18 | ; CHECK: Running analysis: LoopAccessAnalysis on inner2.header |
| 19 | ; CHECK: Finished Loop pass manager run. |
| 20 | ; CHECK: Starting Loop pass manager run. |
| 21 | ; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis |
| 22 | ; CHECK: Running analysis: LoopAccessAnalysis on outer.header |
| 23 | ; CHECK: Finished Loop pass manager run. |
| 24 | ; CHECK: Running pass: LoopUnrollPass |
Sanjoy Das | def1729 | 2017-09-28 02:45:42 +0000 | [diff] [blame] | 25 | ; CHECK: Clearing all analysis results for: inner2.header |
| 26 | ; CHECK: Clearing all analysis results for: outer.header |
Chandler Carruth | 7c888dc | 2017-08-08 02:24:20 +0000 | [diff] [blame] | 27 | ; CHECK: Invalidating all non-preserved analyses for: test |
| 28 | ; CHECK: Invalidating all non-preserved analyses for: inner1.header |
| 29 | ; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header |
| 30 | ; CHECK: Invalidating all non-preserved analyses for: inner1.header.1 |
| 31 | ; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1 |
| 32 | ; CHECK: Running pass: FunctionToLoopPassAdaptor |
| 33 | ; CHECK: Starting Loop pass manager run. |
| 34 | ; CHECK: Running pass: LoopAccessInfoPrinterPass |
| 35 | ; CHECK: Running analysis: LoopAccessAnalysis on inner1.header |
| 36 | ; CHECK: Loop access info in function 'test': |
| 37 | ; CHECK: inner1.header: |
| 38 | ; CHECK: Finished Loop pass manager run. |
| 39 | ; CHECK: Starting Loop pass manager run. |
| 40 | ; CHECK: Running pass: LoopAccessInfoPrinterPass |
| 41 | ; CHECK: Running analysis: LoopAccessAnalysis on inner1.header.1 |
| 42 | ; CHECK: Loop access info in function 'test': |
| 43 | ; CHECK: inner1.header.1: |
| 44 | ; CHECK: Finished Loop pass manager run. |
| 45 | |
| 46 | target triple = "x86_64-unknown-linux-gnu" |
| 47 | |
| 48 | define void @test(i32 %inner1.count) { |
| 49 | ; CHECK-LABEL: define void @test( |
| 50 | bb: |
| 51 | br label %outer.ph |
| 52 | |
| 53 | outer.ph: |
| 54 | br label %outer.header |
| 55 | |
| 56 | outer.header: |
| 57 | %outer.i = phi i32 [ 0, %outer.ph ], [ %outer.i.next, %outer.latch ] |
| 58 | br label %inner1.ph |
| 59 | |
| 60 | inner1.ph: |
| 61 | br label %inner1.header |
| 62 | |
| 63 | inner1.header: |
| 64 | %inner1.i = phi i32 [ 0, %inner1.ph ], [ %inner1.i.next, %inner1.header ] |
| 65 | %inner1.i.next = add i32 %inner1.i, 1 |
| 66 | %inner1.cond = icmp eq i32 %inner1.i, %inner1.count |
| 67 | br i1 %inner1.cond, label %inner1.exit, label %inner1.header |
| 68 | ; We should have two unrolled copies of this loop and nothing else. |
| 69 | ; |
| 70 | ; CHECK-NOT: icmp eq |
| 71 | ; CHECK-NOT: br i1 |
| 72 | ; CHECK: %[[COND1:.*]] = icmp eq i32 %{{.*}}, %inner1.count |
| 73 | ; CHECK: br i1 %[[COND1]], |
| 74 | ; CHECK-NOT: icmp eq |
| 75 | ; CHECK-NOT: br i1 |
| 76 | ; CHECK: %[[COND2:.*]] = icmp eq i32 %{{.*}}, %inner1.count |
| 77 | ; CHECK: br i1 %[[COND2]], |
| 78 | ; CHECK-NOT: icmp eq |
| 79 | ; CHECK-NOT: br i1 |
| 80 | |
| 81 | |
| 82 | inner1.exit: |
| 83 | br label %inner2.ph |
| 84 | |
| 85 | inner2.ph: |
| 86 | br label %inner2.header |
| 87 | |
| 88 | inner2.header: |
| 89 | %inner2.i = phi i32 [ 0, %inner2.ph ], [ %inner2.i.next, %inner2.header ] |
| 90 | %inner2.i.next = add i32 %inner2.i, 1 |
| 91 | %inner2.cond = icmp eq i32 %inner2.i, 4 |
| 92 | br i1 %inner2.cond, label %inner2.exit, label %inner2.header |
| 93 | |
| 94 | inner2.exit: |
| 95 | br label %outer.latch |
| 96 | |
| 97 | outer.latch: |
| 98 | %outer.i.next = add i32 %outer.i, 1 |
| 99 | %outer.cond = icmp eq i32 %outer.i.next, 2 |
| 100 | br i1 %outer.cond, label %outer.exit, label %outer.header |
| 101 | |
| 102 | outer.exit: |
| 103 | br label %exit |
| 104 | |
| 105 | exit: |
| 106 | ret void |
| 107 | } |