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
| ; RUN: opt -S -loop-unroll -unroll-runtime < %s | FileCheck %s
; Epilog unroll allows to keep PHI constant value.
; For the test this means that after unroll XOR could be deleted.
; Check that we do epilogue reminder here.
; CHECK-LABEL: const_phi_val
; CHECK: for.body.epil
; Function Attrs: norecurse nounwind uwtable
define void @const_phi_val(i32 %i0, i32* nocapture %a) {
entry:
%cmp6 = icmp slt i32 %i0, 1000
br i1 %cmp6, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%tmp = sext i32 %i0 to i64
br label %for.body
for.body: ; preds = %for.body, %for.body.preheader
%indvars.iv = phi i64 [ %tmp, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
%s.08 = phi i32 [ 0, %for.body.preheader ], [ %xor, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
store i32 %s.08, i32* %arrayidx, align 4
%xor = xor i32 %s.08, 1
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%exitcond = icmp eq i64 %indvars.iv.next, 1000
br i1 %exitcond, label %for.end.loopexit, label %for.body
for.end.loopexit: ; preds = %for.body
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
ret void
}
; When there is no phi with const coming from preheader,
; there is no need to do epilogue unrolling.
; CHECK-LABEL: var_phi_val
; CHECK: for.body.prol
; Function Attrs: norecurse nounwind uwtable
define void @var_phi_val(i32 %i0, i32* nocapture %a) {
entry:
%cmp6 = icmp slt i32 %i0, 1000
br i1 %cmp6, label %for.body.preheader, label %for.end
for.body.preheader: ; preds = %entry
%tmp = sext i32 %i0 to i64
br label %for.body
for.body: ; preds = %for.body, %for.body.preheader
%indvars.iv = phi i64 [ %tmp, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
%indvars.iv.next = add nsw i64 %indvars.iv, 1
%exitcond = icmp eq i64 %indvars.iv.next, 1000
br i1 %exitcond, label %for.end.loopexit, label %for.body
for.end.loopexit: ; preds = %for.body
br label %for.end
for.end: ; preds = %for.end.loopexit, %entry
ret void
}
|