1; RUN: opt %loadPolly -polly-detect -analyze < %s | FileCheck %s
2;
3; Check that we will recognize this SCoP.
4;
5;    void f(int *A, long N) {
6;      int j = 0;
7;      while (N > j) {
8;        int x = A[0];
9;        int i = 1;
10;        do {
11;          A[x] = 42;
12;          A += x;
13;        } while (i++ < N);
14;      }
15;    }
16;
17; CHECK: Valid Region for Scop: bb1 => bb0
18;
19target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20
21define void @f(i32* %A, i64 %N) {
22bb:
23  br label %bb0
24
25bb0:
26  %j = phi i64 [ %j.next, %bb1 ], [ 1, %bb ]
27  %tmp = load i32, i32* %A, align 4
28  %exitcond0 = icmp sgt i64 %N, %j
29  %j.next = add nuw nsw i64 %j, 1
30  br i1 %exitcond0, label %bb1, label %bb13
31
32bb1:                                              ; preds = %bb7, %bb0
33  %i = phi i64 [ %i.next, %bb1 ], [ 1, %bb0 ]
34  %.0 = phi i32* [ %A, %bb0 ], [ %tmp12, %bb1 ]
35  %tmp8 = sext i32 %tmp to i64
36  %tmp9 = getelementptr inbounds i32, i32* %.0, i64 %tmp8
37  store i32 42, i32* %tmp9, align 4
38  %tmp11 = sext i32 %tmp to i64
39  %tmp12 = getelementptr inbounds i32, i32* %.0, i64 %tmp11
40  %i.next = add nuw nsw i64 %i, 1
41  %exitcond = icmp ne i64 %i, %N
42  br i1 %exitcond, label %bb1, label %bb0
43
44bb13:                                             ; preds = %bb1
45  ret void
46}
47