Fix Polly
[polly-mirror.git] / test / ScopInfo / isl_trip_count_03.ll
blob61b29e4f4f87fd4bf21263b2e7ccb824664a5ee6
1 ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
3 ; Test comes from a bug (15771) or better a feature request. It was not allowed
4 ; in Polly in the old domain generation as ScalarEvolution cannot figure out the
5 ; loop bounds. However, the new domain generation will detect the SCoP.
7 ; CHECK:      Context:
8 ; CHECK-NEXT: [n] -> {  : -2147483648 <= n <= 2147483647 }
10 ; CHECK:      p0: %n
12 ; CHECK:      Statements {
13 ; CHECK-NEXT:     Stmt_for_next
14 ; CHECK-NEXT:         Domain :=
15 ; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] : i0 >= 0 and 2i0 <= -3 + n };
16 ; CHECK-NEXT:         Schedule :=
17 ; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> [i0] };
18 ; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
19 ; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> MemRef_A[i0] };
20 ; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: +] [Scalar: 0]
21 ; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> MemRef_A[i0] };
22 ; CHECK-NEXT: }
24 @A = common global [100 x i32] zeroinitializer, align 16
26 define void @foo(i32 %n) #0 {
27 entry:
28   br label %entry.split
30 entry.split:                                      ; preds = %entry
31   %cmp2 = icmp sgt i32 %n, 0
32   br i1 %cmp2, label %for.body.lr.ph, label %for.end
34 for.body.lr.ph:                                   ; preds = %entry.split
35   br label %for.body
37 for.body:                                         ; preds = %for.body.lr.ph, %for.body
38   %indvar = phi i64 [ 0, %for.body.lr.ph ], [ %indvar.next, %for.next ]
39   %arrayidx = getelementptr [100 x i32], [100 x i32]* @A, i64 0, i64 %indvar
40   %0 = mul i64 %indvar, 2
41   %1 = add i64 %0, 2
42   %add1 = trunc i64 %1 to i32
43   %cmp = icmp slt i32 %add1, %n
44   %indvar.next = add i64 %indvar, 1
45   br i1 %cmp, label %for.next, label %for.cond.for.end_crit_edge
47 for.next:
48   %2 = load i32, i32* %arrayidx, align 4
49   %add = add nsw i32 %2, 1
50   store i32 %add, i32* %arrayidx, align 4
51   br label %for.body
53 for.cond.for.end_crit_edge:                       ; preds = %for.body
54   br label %for.end
56 for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry.split
57   ret void