1; RUN: opt %loadPolly -polly-allow-nonaffine -S < %s | FileCheck %s --check-prefix=CODE
2; RUN: opt %loadPolly -polly-allow-nonaffine -polly-scops -analyze < %s | FileCheck %s
3;
4; Verify there is a phi in the non-affine region but it is not represented in
5; the SCoP as all operands as well as the uses are inside the region too.
6;
7;    void f(int *A) {
8;      for (int i = 0; i < 1024; i++) {
9;        if (A[i]) {
10;          int x = 0;
11;          if (i > 512)
12;            x = 1 + A[i];
13;          A[i] = x;
14;        }
15;      }
16;    }
17;
18; CODE-LABEL: bb11:
19; CODE:         %x.0 = phi i32
20;
21; We have 3 accesses to A that should be present in the SCoP but no scalar access.
22;
23; CHECK-NOT: [Scalar: 1]
24; CHECK:     [Scalar: 0]
25; CHECK-NOT: [Scalar: 1]
26; CHECK:     [Scalar: 0]
27; CHECK-NOT: [Scalar: 1]
28; CHECK:     [Scalar: 0]
29; CHECK-NOT: [Scalar: 1]
30;
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32
33define void @f(i32* %A) {
34bb:
35  br label %bb1
36
37bb1:                                              ; preds = %bb14, %bb
38  %indvars.iv = phi i64 [ %indvars.iv.next, %bb14 ], [ 0, %bb ]
39  %exitcond = icmp ne i64 %indvars.iv, 1024
40  br i1 %exitcond, label %bb2, label %bb15
41
42bb2:                                              ; preds = %bb1
43  %tmp = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
44  %tmp3 = load i32,  i32* %tmp, align 4
45  %tmp4 = icmp eq i32 %tmp3, 0
46  br i1 %tmp4, label %bb13, label %bb5
47
48bb5:                                              ; preds = %bb2
49  %tmp6 = icmp sgt i64 %indvars.iv, 512
50  br i1 %tmp6, label %bb7, label %bb11
51
52bb7:                                              ; preds = %bb5
53  %tmp8 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
54  %tmp9 = load i32,  i32* %tmp8, align 4
55  %tmp10 = add nsw i32 %tmp9, 1
56  br label %bb11
57
58bb11:                                             ; preds = %bb7, %bb5
59  %x.0 = phi i32 [ %tmp10, %bb7 ], [ 0, %bb5 ]
60  %tmp12 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
61  store i32 %x.0, i32* %tmp12, align 4
62  br label %bb13
63
64bb13:                                             ; preds = %bb2, %bb11
65  br label %bb14
66
67bb14:                                             ; preds = %bb13
68  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
69  br label %bb1
70
71bb15:                                             ; preds = %bb1
72  ret void
73}
74