• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S  -loop-reroll   %s | FileCheck %s
2target triple = "aarch64--linux-gnu"
3
4define i32 @test(i32* readonly %buf, i32* readnone %end) #0 {
5entry:
6  %cmp.9 = icmp eq i32* %buf, %end
7  br i1 %cmp.9, label %while.end, label %while.body.preheader
8
9while.body.preheader:
10  br label %while.body
11
12while.body:
13;CHECK-LABEL: while.body:
14;CHECK-NEXT:    %indvar = phi i64 [ %indvar.next, %while.body ], [ 0, %while.body.preheader ]
15;CHECK-NEXT:    %S.011 = phi i32 [ %add, %while.body ], [ undef, %while.body.preheader ]
16;CHECK-NEXT:    %scevgep = getelementptr i32, i32* %buf, i64 %indvar
17;CHECK-NEXT:    %4 = load i32, i32* %scevgep, align 4
18;CHECK-NEXT:    %add = add nsw i32 %4, %S.011
19;CHECK-NEXT:    %indvar.next = add i64 %indvar, 1
20;CHECK-NEXT:    %exitcond = icmp eq i32* %scevgep, %scevgep5
21;CHECK-NEXT:    br i1 %exitcond, label %while.end.loopexit, label %while.body
22
23  %S.011 = phi i32 [ %add2, %while.body ], [ undef, %while.body.preheader ]
24  %buf.addr.010 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
25  %0 = load i32, i32* %buf.addr.010, align 4
26  %add = add nsw i32 %0, %S.011
27  %arrayidx1 = getelementptr inbounds i32, i32* %buf.addr.010, i64 1
28  %1 = load i32, i32* %arrayidx1, align 4
29  %add2 = add nsw i32 %add, %1
30  %add.ptr = getelementptr inbounds i32, i32* %buf.addr.010, i64 2
31  %cmp = icmp eq i32* %add.ptr, %end
32  br i1 %cmp, label %while.end.loopexit, label %while.body
33
34while.end.loopexit:
35  %add2.lcssa = phi i32 [ %add2, %while.body ]
36  br label %while.end
37
38while.end:
39  %S.0.lcssa = phi i32 [ undef, %entry ], [ %add2.lcssa, %while.end.loopexit ]
40  ret i32 %S.0.lcssa
41}
42
43define i32 @test2(i32* readonly %buf, i32* readnone %end) #0 {
44entry:
45  %cmp.9 = icmp eq i32* %buf, %end
46  br i1 %cmp.9, label %while.end, label %while.body.preheader
47
48while.body.preheader:
49  br label %while.body
50
51while.body:
52;CHECK-LABEL: while.body:
53;CHECK-NEXT:    %indvar = phi i64 [ %indvar.next, %while.body ], [ 0, %while.body.preheader ]
54;CHECK-NEXT:    %S.011 = phi i32 [ %add, %while.body ], [ undef, %while.body.preheader ]
55;CHECK-NEXT:    %4 = mul i64 %indvar, -1
56;CHECK-NEXT:    %scevgep = getelementptr i32, i32* %buf, i64 %4
57;CHECK-NEXT:    %5 = load i32, i32* %scevgep, align 4
58;CHECK-NEXT:    %add = add nsw i32 %5, %S.011
59;CHECK-NEXT:    %indvar.next = add i64 %indvar, 1
60;CHECK-NEXT:    %exitcond = icmp eq i32* %scevgep, %scevgep5
61;CHECK-NEXT:    br i1 %exitcond, label %while.end.loopexit, label %while.body
62
63  %S.011 = phi i32 [ %add2, %while.body ], [ undef, %while.body.preheader ]
64  %buf.addr.010 = phi i32* [ %add.ptr, %while.body ], [ %buf, %while.body.preheader ]
65  %0 = load i32, i32* %buf.addr.010, align 4
66  %add = add nsw i32 %0, %S.011
67  %arrayidx1 = getelementptr inbounds i32, i32* %buf.addr.010, i64 -1
68  %1 = load i32, i32* %arrayidx1, align 4
69  %add2 = add nsw i32 %add, %1
70  %add.ptr = getelementptr inbounds i32, i32* %buf.addr.010, i64 -2
71  %cmp = icmp eq i32* %add.ptr, %end
72  br i1 %cmp, label %while.end.loopexit, label %while.body
73
74while.end.loopexit:
75  %add2.lcssa = phi i32 [ %add2, %while.body ]
76  br label %while.end
77
78while.end:
79  %S.0.lcssa = phi i32 [ undef, %entry ], [ %add2.lcssa, %while.end.loopexit ]
80  ret i32 %S.0.lcssa
81}
82