File: unroll-loop-invalidation.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (91 lines) | stat: -rw-r--r-- 3,303 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
; This test exercises that we don't corrupt a loop-analysis when running loop
; unrolling in a way that deletes a loop. To do that, we first ensure the
; analysis is cached, then unroll the loop (deleting it) and make sure that the
; next function doesn't get a cache "hit" for this stale analysis result.
;
; RUN: opt -S -passes='loop(require<access-info>),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s
;
; CHECK: Running analysis: LoopAnalysis
; CHECK: Running analysis: InnerAnalysisManagerProxy<
; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header
; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header
; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis
; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header
; CHECK: Running pass: LoopUnrollPass
; CHECK: Clearing all analysis results for: inner2.header
; CHECK: Clearing all analysis results for: outer.header
; CHECK: Invalidating analysis: LoopAccessAnalysis on {{.*}}inner1.header
; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on {{.*}}inner1.header.1
; CHECK: Running pass: LoopAccessInfoPrinterPass
; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header
; CHECK: Loop access info in function 'test':
; CHECK:   inner1.header:
; CHECK: Running pass: LoopAccessInfoPrinterPass
; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1
; CHECK: Loop access info in function 'test':
; CHECK:   inner1.header.1:

target triple = "x86_64-unknown-linux-gnu"

define void @test(i32 %inner1.count) {
; CHECK-LABEL: define void @test(
bb:
  br label %outer.ph

outer.ph:
  br label %outer.header

outer.header:
  %outer.i = phi i32 [ 0, %outer.ph ], [ %outer.i.next, %outer.latch ]
  br label %inner1.ph

inner1.ph:
  br label %inner1.header

inner1.header:
  %inner1.i = phi i32 [ 0, %inner1.ph ], [ %inner1.i.next, %inner1.header ]
  %inner1.i.next = add i32 %inner1.i, 1
  %inner1.cond = icmp eq i32 %inner1.i, %inner1.count
  br i1 %inner1.cond, label %inner1.exit, label %inner1.header
; We should have two unrolled copies of this loop and nothing else.
;
; CHECK-NOT:     icmp eq
; CHECK-NOT:     br i1
; CHECK:         %[[COND1:.*]] = icmp eq i32 %{{.*}}, %inner1.count
; CHECK:         br i1 %[[COND1]],
; CHECK-NOT:     icmp eq
; CHECK-NOT:     br i1
; CHECK:         %[[COND2:.*]] = icmp eq i32 %{{.*}}, %inner1.count
; CHECK:         br i1 %[[COND2]],
; CHECK-NOT:     icmp eq
; CHECK-NOT:     br i1


inner1.exit:
  br label %inner2.ph

inner2.ph:
  br label %inner2.header

inner2.header:
  %inner2.i = phi i32 [ 0, %inner2.ph ], [ %inner2.i.next, %inner2.header ]
  %inner2.i.next = add i32 %inner2.i, 1
  %inner2.cond = icmp eq i32 %inner2.i, 4
  br i1 %inner2.cond, label %inner2.exit, label %inner2.header

inner2.exit:
  br label %outer.latch

outer.latch:
  %outer.i.next = add i32 %outer.i, 1
  %outer.cond = icmp eq i32 %outer.i.next, 2
  br i1 %outer.cond, label %outer.exit, label %outer.header

outer.exit:
  br label %exit

exit:
  ret void
}