1; RUN: llc -march=hexagon -mcpu=hexagonv5 -enable-pipeliner < %s -pipeliner-experimental-cg=true | FileCheck %s
2
3; Make sure we attempt to pipeline all inner most loops.
4
5; Check if the first loop is pipelined.
6; CHECK: loop0(.LBB0_[[LOOP:.]],
7; CHECK: .LBB0_[[LOOP]]:
8; CHECK: add(r{{[0-9]+}},r{{[0-9]+}})
9; CHECK-NEXT: memw(r{{[0-9]+}}++#4)
10; CHECK-NEXT: endloop0
11
12; Check if the second loop is pipelined.
13; CHECK: loop0(.LBB0_[[LOOP:.]],
14; CHECK: .LBB0_[[LOOP]]:
15; CHECK: add(r{{[0-9]+}},r{{[0-9]+}})
16; CHECK-NEXT: memw(r{{[0-9]+}}++#4)
17; CHECK-NEXT: endloop0
18
19define i32 @test(i32* %a, i32 %n, i32 %l) {
20entry:
21  %cmp23 = icmp sgt i32 %n, 0
22  br i1 %cmp23, label %for.body3.lr.ph.preheader, label %for.end14
23
24for.body3.lr.ph.preheader:
25  br label %for.body3.lr.ph
26
27for.body3.lr.ph:
28  %sum1.026 = phi i32 [ %add8, %for.inc12 ], [ 0, %for.body3.lr.ph.preheader ]
29  %sum.025 = phi i32 [ %add, %for.inc12 ], [ 0, %for.body3.lr.ph.preheader ]
30  %j.024 = phi i32 [ %inc13, %for.inc12 ], [ 0, %for.body3.lr.ph.preheader ]
31  br label %for.body3
32
33for.body3:
34  %sum.118 = phi i32 [ %sum.025, %for.body3.lr.ph ], [ %add, %for.body3 ]
35  %arrayidx.phi = phi i32* [ %a, %for.body3.lr.ph ], [ %arrayidx.inc, %for.body3 ]
36  %i.017 = phi i32 [ 0, %for.body3.lr.ph ], [ %inc, %for.body3 ]
37  %0 = load i32, i32* %arrayidx.phi, align 4
38  %add = add nsw i32 %0, %sum.118
39  %inc = add nsw i32 %i.017, 1
40  %exitcond = icmp eq i32 %inc, %n
41  %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1
42  br i1 %exitcond, label %for.end, label %for.body3
43
44for.end:
45  tail call void @bar(i32* %a) #2
46  br label %for.body6
47
48for.body6:
49  %sum1.121 = phi i32 [ %sum1.026, %for.end ], [ %add8, %for.body6 ]
50  %arrayidx7.phi = phi i32* [ %a, %for.end ], [ %arrayidx7.inc, %for.body6 ]
51  %i.120 = phi i32 [ 0, %for.end ], [ %inc10, %for.body6 ]
52  %1 = load i32, i32* %arrayidx7.phi, align 4
53  %add8 = add nsw i32 %1, %sum1.121
54  %inc10 = add nsw i32 %i.120, 1
55  %exitcond29 = icmp eq i32 %inc10, %n
56  %arrayidx7.inc = getelementptr i32, i32* %arrayidx7.phi, i32 1
57  br i1 %exitcond29, label %for.inc12, label %for.body6
58
59for.inc12:
60  %inc13 = add nsw i32 %j.024, 1
61  %exitcond30 = icmp eq i32 %inc13, %n
62  br i1 %exitcond30, label %for.end14.loopexit, label %for.body3.lr.ph
63
64for.end14.loopexit:
65  br label %for.end14
66
67for.end14:
68  %sum1.0.lcssa = phi i32 [ 0, %entry ], [ %add8, %for.end14.loopexit ]
69  %sum.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.end14.loopexit ]
70  %add15 = add nsw i32 %sum1.0.lcssa, %sum.0.lcssa
71  ret i32 %add15
72}
73
74declare void @bar(i32*)
75
76