Skip to content

Commit ca4d8de

Browse files
committed
Update tests to account for new remarks
1 parent dc9cfca commit ca4d8de

File tree

7 files changed

+243
-1
lines changed

7 files changed

+243
-1
lines changed

llvm/lib/Transforms/Scalar/LoopInterchange.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ static bool hasSupportedLoopDepth(SmallVectorImpl<Loop *> &LoopList,
272272
return true;
273273
}
274274

275-
static bool isComputableLoopNest(ScalarEvolution *SE, ArrayRef<Loop *> LoopList) {
275+
static bool isComputableLoopNest(ScalarEvolution *SE,
276+
ArrayRef<Loop *> LoopList) {
276277
for (Loop *L : LoopList) {
277278
const SCEV *ExitCountOuter = SE->getBackedgeTakenCount(L);
278279
if (isa<SCEVCouldNotCompute>(ExitCountOuter)) {
@@ -1760,6 +1761,12 @@ PreservedAnalyses LoopInterchangePass::run(LoopNest &LN,
17601761
return PreservedAnalyses::all();
17611762
}
17621763

1764+
ORE.emit([&]() {
1765+
return OptimizationRemark(DEBUG_TYPE, "Dependence",
1766+
LN.getOutermostLoop().getStartLoc(), LN.getOutermostLoop().getHeader())
1767+
<< "Computed dependence info, invoking the transform.";
1768+
});
1769+
17631770
DependenceInfo DI(&F, &AR.AA, &AR.SE, &AR.LI);
17641771
std::unique_ptr<CacheCost> CC =
17651772
CacheCost::getCacheCost(LN.getOutermostLoop(), AR, DI);

llvm/test/Transforms/LoopInterchange/loop-interchange-optimization-remarks.ll

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ for.end19:
5858
ret void
5959
}
6060

61+
; CHECK: --- !Passed
62+
; CHECK-NEXT: Pass: loop-interchange
63+
; CHECK-NEXT: Name: Dependence
64+
; CHECK-NEXT: Function: test01
65+
; CHECK-NEXT: Args:
66+
; CHECK-NEXT: - String: Computed dependence info, invoking the transform.
67+
; CHECK-NEXT: ...
68+
6169
; CHECK: --- !Missed
6270
; CHECK-NEXT: Pass: loop-interchange
6371
; CHECK-NEXT: Name: Dependence
@@ -66,6 +74,14 @@ for.end19:
6674
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
6775
; CHECK-NEXT: ...
6876

77+
; DELIN: --- !Passed
78+
; DELIN-NEXT: Pass: loop-interchange
79+
; DELIN-NEXT: Name: Dependence
80+
; DELIN-NEXT: Function: test01
81+
; DELIN-NEXT: Args:
82+
; DELIN-NEXT: - String: Computed dependence info, invoking the transform.
83+
; DELIN-NEXT: ...
84+
6985
; DELIN: --- !Missed
7086
; DELIN-NEXT: Pass: loop-interchange
7187
; DELIN-NEXT: Name: InterchangeNotProfitable
@@ -118,6 +134,14 @@ define void @test02(i32 %k, i32 %N) {
118134
ret void
119135
}
120136

137+
; CHECK: --- !Passed
138+
; CHECK-NEXT: Pass: loop-interchange
139+
; CHECK-NEXT: Name: Dependence
140+
; CHECK-NEXT: Function: test02
141+
; CHECK-NEXT: Args:
142+
; CHECK-NEXT: - String: Computed dependence info, invoking the transform.
143+
; CHECK-NEXT: ...
144+
121145
; CHECK: --- !Missed
122146
; CHECK-NEXT: Pass: loop-interchange
123147
; CHECK-NEXT: Name: Dependence
@@ -126,6 +150,14 @@ define void @test02(i32 %k, i32 %N) {
126150
; CHECK-NEXT: - String: Cannot interchange loops due to dependences.
127151
; CHECK-NEXT: ...
128152

153+
; DELIN: --- !Passed
154+
; DELIN-NEXT: Pass: loop-interchange
155+
; DELIN-NEXT: Name: Dependence
156+
; DELIN-NEXT: Function: test02
157+
; DELIN-NEXT: Args:
158+
; DELIN-NEXT: - String: Computed dependence info, invoking the transform.
159+
; DELIN-NEXT: ...
160+
129161
; DELIN: --- !Passed
130162
; DELIN-NEXT: Pass: loop-interchange
131163
; DELIN-NEXT: Name: Interchanged
@@ -174,6 +206,14 @@ for.body4: ; preds = %for.body4, %for.con
174206
br i1 %exitcond, label %for.body4, label %for.cond.loopexit
175207
}
176208

209+
; CHECK: --- !Passed
210+
; CHECK-NEXT: Pass: loop-interchange
211+
; CHECK-NEXT: Name: Dependence
212+
; CHECK-NEXT: Function: test03
213+
; CHECK-NEXT: Args:
214+
; CHECK-NEXT: - String: Computed dependence info, invoking the transform.
215+
; CHECK-NEXT: ...
216+
177217
; CHECK: --- !Passed
178218
; CHECK-NEXT: Pass: loop-interchange
179219
; CHECK-NEXT: Name: Interchanged
@@ -182,6 +222,14 @@ for.body4: ; preds = %for.body4, %for.con
182222
; CHECK-NEXT: - String: Loop interchanged with enclosing loop.
183223
; CHECK-NEXT: ...
184224

225+
; DELIN: --- !Passed
226+
; DELIN-NEXT: Pass: loop-interchange
227+
; DELIN-NEXT: Name: Dependence
228+
; DELIN-NEXT: Function: test03
229+
; DELIN-NEXT: Args:
230+
; DELIN-NEXT: - String: Computed dependence info, invoking the transform.
231+
; DELIN-NEXT: ...
232+
185233
; DELIN: --- !Passed
186234
; DELIN-NEXT: Pass: loop-interchange
187235
; DELIN-NEXT: Name: Interchanged
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
; RUN: opt %s -passes='loop-interchange' -pass-remarks=loop-interchange -disable-output 2>&1 | FileCheck --allow-empty %s
2+
3+
target triple = "aarch64-unknown-linux-gnu"
4+
5+
; CHECK-NOT: Computed dependence info, invoking the transform.
6+
7+
define dso_local void @_foo(ptr noundef %a, ptr noundef %neg, ptr noundef %pos) {
8+
entry:
9+
%a.addr = alloca ptr, align 8
10+
%neg.addr = alloca ptr, align 8
11+
%pos.addr = alloca ptr, align 8
12+
%p = alloca i32, align 4
13+
%q = alloca i32, align 4
14+
%i = alloca i32, align 4
15+
%cleanup.dest.slot = alloca i32, align 4
16+
%j = alloca i32, align 4
17+
store ptr %a, ptr %a.addr, align 8
18+
store ptr %neg, ptr %neg.addr, align 8
19+
store ptr %pos, ptr %pos.addr, align 8
20+
store i32 0, ptr %p, align 4
21+
store i32 0, ptr %q, align 4
22+
store i32 0, ptr %i, align 4
23+
br label %for.cond
24+
25+
for.cond: ; preds = %for.inc16, %entry
26+
%0 = load i32, ptr %i, align 4
27+
%cmp = icmp slt i32 %0, 32
28+
br i1 %cmp, label %for.body, label %for.cond.cleanup
29+
30+
for.cond.cleanup: ; preds = %for.cond
31+
store i32 2, ptr %cleanup.dest.slot, align 4
32+
br label %for.end18
33+
34+
for.body: ; preds = %for.cond
35+
store i32 0, ptr %j, align 4
36+
br label %for.cond1
37+
38+
for.cond1: ; preds = %for.inc, %for.body
39+
%1 = load i32, ptr %j, align 4
40+
%cmp2 = icmp slt i32 %1, 32
41+
br i1 %cmp2, label %for.body4, label %for.cond.cleanup3
42+
43+
for.cond.cleanup3: ; preds = %for.cond1
44+
store i32 5, ptr %cleanup.dest.slot, align 4
45+
br label %for.end
46+
47+
for.body4: ; preds = %for.cond1
48+
%2 = load ptr, ptr %a.addr, align 8
49+
%3 = load i32, ptr %i, align 4
50+
%idxprom = sext i32 %3 to i64
51+
%arrayidx = getelementptr inbounds i32, ptr %2, i64 %idxprom
52+
%4 = load i32, ptr %arrayidx, align 4
53+
%cmp5 = icmp slt i32 %4, 0
54+
br i1 %cmp5, label %if.then, label %if.else
55+
56+
if.then: ; preds = %for.body4
57+
%5 = load ptr, ptr %a.addr, align 8
58+
%6 = load i32, ptr %i, align 4
59+
%idxprom6 = sext i32 %6 to i64
60+
%arrayidx7 = getelementptr inbounds i32, ptr %5, i64 %idxprom6
61+
%7 = load i32, ptr %arrayidx7, align 4
62+
%8 = load ptr, ptr %neg.addr, align 8
63+
%9 = load i32, ptr %p, align 4
64+
%inc = add nsw i32 %9, 1
65+
store i32 %inc, ptr %p, align 4
66+
%idxprom8 = sext i32 %9 to i64
67+
%arrayidx9 = getelementptr inbounds i32, ptr %8, i64 %idxprom8
68+
store i32 %7, ptr %arrayidx9, align 4
69+
br label %if.end
70+
71+
if.else: ; preds = %for.body4
72+
%10 = load ptr, ptr %a.addr, align 8
73+
%11 = load i32, ptr %i, align 4
74+
%idxprom10 = sext i32 %11 to i64
75+
%arrayidx11 = getelementptr inbounds i32, ptr %10, i64 %idxprom10
76+
%12 = load i32, ptr %arrayidx11, align 4
77+
%13 = load ptr, ptr %pos.addr, align 8
78+
%14 = load i32, ptr %q, align 4
79+
%inc12 = add nsw i32 %14, 1
80+
store i32 %inc12, ptr %q, align 4
81+
%idxprom13 = sext i32 %14 to i64
82+
%arrayidx14 = getelementptr inbounds i32, ptr %13, i64 %idxprom13
83+
store i32 %12, ptr %arrayidx14, align 4
84+
br label %if.end
85+
86+
if.end: ; preds = %if.else, %if.then
87+
br label %for.inc
88+
89+
for.inc: ; preds = %if.end
90+
%15 = load i32, ptr %j, align 4
91+
%inc15 = add nsw i32 %15, 1
92+
store i32 %inc15, ptr %j, align 4
93+
br label %for.cond1
94+
95+
for.end: ; preds = %for.cond.cleanup3
96+
br label %for.inc16
97+
98+
for.inc16: ; preds = %for.end
99+
%16 = load i32, ptr %i, align 4
100+
%inc17 = add nsw i32 %16, 1
101+
store i32 %inc17, ptr %i, align 4
102+
br label %for.cond
103+
104+
for.end18: ; preds = %for.cond.cleanup
105+
ret void
106+
}
107+

llvm/test/Transforms/LoopInterchange/pr43326-ideal-access-pattern.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
; }
1515
; }
1616

17+
; REMARKS: --- !Passed
18+
; REMARKS-NEXT: Pass: loop-interchange
19+
; REMARKS-NEXT: Name: Dependence
20+
; REMARKS-NEXT: Function: pr43326-triply-nested
21+
; REMARKS-NEXT: Args:
22+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
23+
; REMARKS-NEXT: ...
24+
1725
; REMARKS: --- !Passed
1826
; REMARKS-NEXT: Pass: loop-interchange
1927
; REMARKS-NEXT: Name: Interchanged

llvm/test/Transforms/LoopInterchange/pr43326.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
@d = global i32 0
99
@e = global [1 x [1 x i32]] zeroinitializer
1010

11+
; REMARKS: --- !Passed
12+
; REMARKS-NEXT: Pass: loop-interchange
13+
; REMARKS-NEXT: Name: Dependence
14+
; REMARKS-NEXT: Function: pr43326
15+
; REMARKS-NEXT: Args:
16+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
17+
; REMARKS-NEXT: ...
18+
1119
; REMARKS: --- !Passed
1220
; REMARKS-NEXT: Pass: loop-interchange
1321
; REMARKS-NEXT: Name: Interchanged

llvm/test/Transforms/LoopInterchange/pr48212.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
; RUN: -verify-dom-info -verify-loop-info -verify-loop-lcssa 2>&1
33
; RUN: FileCheck --input-file=%t --check-prefix=REMARKS %s
44

5+
; REMARKS: --- !Passed
6+
; REMARKS-NEXT: Pass: loop-interchange
7+
; REMARKS-NEXT: Name: Dependence
8+
; REMARKS-NEXT: Function: pr48212
9+
; REMARKS-NEXT: Args:
10+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
11+
; REMARKS-NEXT: ...
12+
513
; REMARKS: --- !Passed
614
; REMARKS-NEXT: Pass: loop-interchange
715
; REMARKS-NEXT: Name: Interchanged

llvm/test/Transforms/LoopInterchange/reductions-across-inner-and-outer-loop.ll

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55

66
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
77

8+
; REMARKS: --- !Passed
9+
; REMARKS-NEXT: Pass: loop-interchange
10+
; REMARKS-NEXT: Name: Dependence
11+
; REMARKS-NEXT: Function: test1
12+
; REMARKS-NEXT: Args:
13+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
14+
; REMARKS-NEXT: ...
15+
816
; REMARKS: --- !Passed
917
; REMARKS-NEXT: Pass: loop-interchange
1018
; REMARKS-NEXT: Name: Interchanged
@@ -77,6 +85,14 @@ for1.loopexit: ; preds = %for1.inc
7785

7886
; In this test case, the inner reduction PHI %inner does not involve the outer
7987
; reduction PHI %sum.outer, do not interchange.
88+
; REMARKS: --- !Passed
89+
; REMARKS-NEXT: Pass: loop-interchange
90+
; REMARKS-NEXT: Name: Dependence
91+
; REMARKS-NEXT: Function: test2
92+
; REMARKS-NEXT: Args:
93+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
94+
; REMARKS-NEXT: ...
95+
8096
; REMARKS: --- !Missed
8197
; REMARKS-NEXT: Pass: loop-interchange
8298
; REMARKS-NEXT: Name: UnsupportedPHIOuter
@@ -114,6 +130,14 @@ for1.loopexit: ; preds = %for1.inc
114130

115131
; Check that we do not interchange if there is an additional instruction
116132
; between the outer and inner reduction PHIs.
133+
; REMARKS: --- !Passed
134+
; REMARKS-NEXT: Pass: loop-interchange
135+
; REMARKS-NEXT: Name: Dependence
136+
; REMARKS-NEXT: Function: test3
137+
; REMARKS-NEXT: Args:
138+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
139+
; REMARKS-NEXT: ...
140+
117141
; REMARKS: --- !Missed
118142
; REMARKS-NEXT: Pass: loop-interchange
119143
; REMARKS-NEXT: Name: UnsupportedPHIOuter
@@ -151,6 +175,14 @@ for1.loopexit: ; preds = %for1.inc
151175
}
152176

153177
; Check that we do not interchange if reduction is stored in an invariant address inside inner loop
178+
; REMARKS: --- !Passed
179+
; REMARKS-NEXT: Pass: loop-interchange
180+
; REMARKS-NEXT: Name: Dependence
181+
; REMARKS-NEXT: Function: test4
182+
; REMARKS-NEXT: Args:
183+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
184+
; REMARKS-NEXT: ...
185+
154186
; REMARKS: --- !Missed
155187
; REMARKS-NEXT: Pass: loop-interchange
156188
; REMARKS-NEXT: Name: Dependence
@@ -190,6 +222,14 @@ for1.loopexit: ; preds = %for1.inc
190222

191223
; Check that we do not interchange or crash if the PHI in the outer loop gets a
192224
; constant from the inner loop.
225+
; REMARKS: --- !Passed
226+
; REMARKS-NEXT: Pass: loop-interchange
227+
; REMARKS-NEXT: Name: Dependence
228+
; REMARKS-NEXT: Function: test_constant_inner_loop_res
229+
; REMARKS-NEXT: Args:
230+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
231+
; REMARKS-NEXT: ...
232+
193233
; REMARKS: --- !Missed
194234
; REMARKS-NEXT: Pass: loop-interchange
195235
; REMARKS-NEXT: Name: UnsupportedPHIOuter
@@ -229,6 +269,14 @@ for1.loopexit: ; preds = %for1.inc
229269

230270
; Floating point reductions are interchanged if all the fp instructions
231271
; involved allow reassociation.
272+
; REMARKS: --- !Passed
273+
; REMARKS-NEXT: Pass: loop-interchange
274+
; REMARKS-NEXT: Name: Dependence
275+
; REMARKS-NEXT: Function: test5
276+
; REMARKS-NEXT: Args:
277+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
278+
; REMARKS-NEXT: ...
279+
232280
; REMARKS: --- !Passed
233281
; REMARKS-NEXT: Pass: loop-interchange
234282
; REMARKS-NEXT: Name: Interchanged
@@ -269,6 +317,14 @@ for.exit: ; preds = %outer.inc
269317

270318
; Floating point reductions are not interchanged if not all the fp instructions
271319
; involved allow reassociation.
320+
; REMARKS: --- !Passed
321+
; REMARKS-NEXT: Pass: loop-interchange
322+
; REMARKS-NEXT: Name: Dependence
323+
; REMARKS-NEXT: Function: test6
324+
; REMARKS-NEXT: Args:
325+
; REMARKS-NEXT: - String: Computed dependence info, invoking the transform.
326+
; REMARKS-NEXT: ...
327+
272328
; REMARKS: --- !Missed
273329
; REMARKS-NEXT: Pass: loop-interchange
274330
; REMARKS-NEXT: Name: UnsupportedPHIOuter

0 commit comments

Comments
 (0)