1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=AFFINE
2; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
3
4; The loop for.body => for.inc has an unpredictable iteration count could due to
5; the undef start value that it is compared to. Therefore the array element
6; %arrayidx101 that depends on that exit value cannot be affine.
7; Derived from test-suite/MultiSource/Benchmarks/BitBench/uuencode/uuencode.c
8
9define void @encode_line(i8* nocapture readonly %input, i32 %octets) {
10entry:
11  br i1 undef, label %for.body, label %for.end
12
13for.body:
14  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
15  %octets.addr.02 = phi i32 [ undef, %for.inc ], [ %octets, %entry ]
16  br i1 false, label %for.inc, label %if.else
17
18if.else:
19  %cond = icmp eq i32 %octets.addr.02, 2
20  br i1 %cond, label %if.then84, label %for.end
21
22if.then84:
23  %0 = add nsw i64 %indvars.iv, 1
24  %arrayidx101 = getelementptr inbounds i8, i8* %input, i64 %0
25  %1 = load i8, i8* %arrayidx101, align 1
26  br label %for.end
27
28for.inc:
29  %cmp = icmp sgt i32 %octets.addr.02, 3
30  %indvars.iv.next = add nsw i64 %indvars.iv, 3
31  br i1 %cmp, label %for.body, label %for.end
32
33for.end:
34  ret void
35}
36
37
38; AFFINE-NOT: Function: encode_line
39
40; NONAFFINE:      Function: encode_line
41; NONAFFINE-NEXT: Region: %for.body---%for.end
42