1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze < %s | \
2; RUN:     FileCheck %s -check-prefix=NONAFFINE
3; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze \
4; RUN:     -polly-allow-nonaffine-branches=false < %s | \
5; RUN:     FileCheck %s -check-prefix=NO-NONEAFFINE
6
7; NONAFFINE:      Statements {
8; NONAFFINE-NEXT: 	Stmt_loop
9; NONAFFINE-NEXT:         Domain :=
10; NONAFFINE-NEXT:             [p] -> { Stmt_loop[0] : p = 100 };
11; NONAFFINE-NEXT:         Schedule :=
12; NONAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> [0, 0] };
13; NONAFFINE-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
14; NONAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> MemRef_A[0] };
15; NONAFFINE-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
16; NONAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> MemRef_cmp[] };
17; NONAFFINE-NEXT: 	Stmt_branch__TO__end
18; NONAFFINE-NEXT:         Domain :=
19; NONAFFINE-NEXT:             [p] -> { Stmt_branch__TO__end[] : p = 100 };
20; NONAFFINE-NEXT:         Schedule :=
21; NONAFFINE-NEXT:             [p] -> { Stmt_branch__TO__end[] -> [1, 0] };
22; NONAFFINE-NEXT:         ReadAccess :=	[Reduction Type: NONE] [Scalar: 1]
23; NONAFFINE-NEXT:             [p] -> { Stmt_branch__TO__end[] -> MemRef_cmp[] };
24; NONAFFINE-NEXT:         MayWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
25; NONAFFINE-NEXT:             [p] -> { Stmt_branch__TO__end[] -> MemRef_A[0] };
26; NONAFFINE-NEXT: }
27
28; NO-NONEAFFINE:      Statements {
29; NO-NONEAFFINE-NEXT:    	Stmt_then
30; NO-NONEAFFINE-NEXT:            Domain :=
31; NO-NONEAFFINE-NEXT:                [p_0, p] -> { Stmt_then[] : p >= 2 + p_0 or p <= p_0 };
32; NO-NONEAFFINE-NEXT:            Schedule :=
33; NO-NONEAFFINE-NEXT:                [p_0, p] -> { Stmt_then[] -> [] };
34; NO-NONEAFFINE-NEXT:            MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
35; NO-NONEAFFINE-NEXT:                [p_0, p] -> { Stmt_then[] -> MemRef_A[0] };
36; NO-NONEAFFINE-NEXT:    }
37
38; NO-NONEAFFINE:      Statements {
39; NO-NONEAFFINE-NEXT: 	Stmt_loop
40; NO-NONEAFFINE-NEXT:         Domain :=
41; NO-NONEAFFINE-NEXT:             [p] -> { Stmt_loop[0] : p = 100 };
42; NO-NONEAFFINE-NEXT:         Schedule :=
43; NO-NONEAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> [0] };
44; NO-NONEAFFINE-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
45; NO-NONEAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> MemRef_A[0] };
46; NO-NONEAFFINE-NEXT:         MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
47; NO-NONEAFFINE-NEXT:             [p] -> { Stmt_loop[i0] -> MemRef_cmp[] };
48; NO-NONEAFFINE-NEXT: }
49
50; Verify that this test case does not crash -polly-scops. The problem in
51; this test case is that the branch instruction in %branch references
52; a scalar evolution expression for which no useful value can be computed at the
53; location %branch, as the loop %loop does not terminate. At some point, we
54; did not identify the branch condition as non-affine during scop detection.
55; This test verifies that we either model the branch condition as non-affine
56; region or only detect a smaller region if non-affine conditions are not
57; allowed.
58
59target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
60target triple = "aarch64--linux-android"
61
62define void @f(i16 %event, i8 %p, float* %A) {
63entry:
64  br label %loop
65
66loop:
67  %indvar = phi i8 [ 0, %entry ], [ %indvar.next, %loop ]
68  %indvar.next = add i8 %indvar, 1
69  store float 1.0, float* %A
70  %cmp = icmp eq i8 %indvar.next, %p
71  %possibly_infinite = icmp eq i8 100, %p
72  br i1 %possibly_infinite, label %branch, label %loop
73
74branch:
75  br i1 %cmp, label %end, label %then
76
77then:
78  store float 1.0, float* %A
79  br label %end
80
81end:
82  ret void
83}
84