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 SCoP contains a loop with multiple exit blocks (BBs after leaving
5; the loop). The current implementation of deriving their domain derives
6; only a common domain for all of the exit blocks. We disabled loops with
7; multiple exit blocks until this is fixed.
8; XFAIL: *
9
10; The loop for.body => for.inc has an unpredictable iteration count could due to
11; the undef start value that it is compared to. Therefore the array element
12; %arrayidx101 that depends on that exit value cannot be affine.
13; Derived from test-suite/MultiSource/Benchmarks/BitBench/uuencode/uuencode.c
14
15define void @encode_line(i8* nocapture readonly %input, i32 %octets, i64 %p) {
16entry:
17  br i1 undef, label %for.body, label %for.end
18
19for.body:
20  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ %p, %entry ]
21  %octets.addr.02 = phi i32 [ undef, %for.inc ], [ %octets, %entry ]
22  br i1 false, label %for.inc, label %if.else
23
24if.else:
25  %cond = icmp eq i32 %octets.addr.02, 2
26  br i1 %cond, label %if.then84, label %for.end
27
28if.then84:
29  %0 = add nsw i64 %indvars.iv, 1
30  %arrayidx101 = getelementptr inbounds i8, i8* %input, i64 %0
31  store i8 42, i8* %arrayidx101, align 1
32  br label %for.end
33
34for.inc:
35  %cmp = icmp sgt i32 %octets.addr.02, 3
36  %indvars.iv.next = add nsw i64 %indvars.iv, 3
37  br i1 %cmp, label %for.body, label %for.end
38
39for.end:
40  ret void
41}
42
43; AFFINE:       Region: %if.else---%for.end
44
45; AFFINE:       Statements {
46; AFFINE-NEXT:  	Stmt_if_then84
47; AFFINE-NEXT:          Domain :=
48; AFFINE-NEXT:              [octets, p_1, p] -> { Stmt_if_then84[] : octets = 2 };
49; AFFINE-NEXT:          Schedule :=
50; AFFINE-NEXT:              [octets, p_1, p] -> { Stmt_if_then84[] -> [] };
51; AFFINE-NEXT:          MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
52; AFFINE-NEXT:              [octets, p_1, p] -> { Stmt_if_then84[] -> MemRef_input[1 + p] };
53; AFFINE-NEXT:  }
54
55; NONAFFINE:      Region: %for.body---%for.end
56
57; NONAFFINE:      Statements {
58; NONAFFINE-NEXT: 	Stmt_for_body
59; NONAFFINE-NEXT:         Domain :=
60; NONAFFINE-NEXT:             [octets] -> { Stmt_for_body[0] };
61; NONAFFINE-NEXT:         Schedule :=
62; NONAFFINE-NEXT:             [octets] -> { Stmt_for_body[i0] -> [0, 0] };
63; NONAFFINE-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
64; NONAFFINE-NEXT:             [octets] -> { Stmt_for_body[i0] -> MemRef_indvars_iv[] };
65; NONAFFINE-NEXT: 	Stmt_if_then84
66; NONAFFINE-NEXT:         Domain :=
67; NONAFFINE-NEXT:             [octets] -> { Stmt_if_then84[] : octets = 2 };
68; NONAFFINE-NEXT:         Schedule :=
69; NONAFFINE-NEXT:             [octets] -> { Stmt_if_then84[] -> [1, 0] };
70; NONAFFINE-NEXT:         ReadAccess :=	[Reduction Type: NONE] [Scalar: 1]
71; NONAFFINE-NEXT:             [octets] -> { Stmt_if_then84[] -> MemRef_indvars_iv[] };
72; NONAFFINE-NEXT:         MayWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
73; NONAFFINE-NEXT:             [octets] -> { Stmt_if_then84[] -> MemRef_input[o0] };
74; NONAFFINE-NEXT: }
75