2 ; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
3 ; RUN: opt %loadPolly -polly-ast -analyze < %s | FileCheck %s --check-prefix=AST
5 ; void f(int *A, int c, int N) {
8 ; for (int j = N; j > 0; j--)
13 ; for (int j = 1; j <= N; j++)
21 ; CHECK-NEXT: Stmt_for_body
22 ; CHECK-NEXT: Domain :=
23 ; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] : c = -1 and 0 <= i0 < N };
24 ; CHECK-NEXT: Schedule :=
25 ; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> [1, i0] };
26 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
27 ; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[-1 + N - i0] };
28 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
29 ; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[N - i0] };
30 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
31 ; CHECK-NEXT: [c, N] -> { Stmt_for_body[i0] -> MemRef_A[N - i0] };
32 ; CHECK-NEXT: Stmt_for_body_7
33 ; CHECK-NEXT: Domain :=
34 ; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] : c = 1 and 0 <= i0 < N };
35 ; CHECK-NEXT: Schedule :=
36 ; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> [0, i0] };
37 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
38 ; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[i0] };
39 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
40 ; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[1 + i0] };
41 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
42 ; CHECK-NEXT: [c, N] -> { Stmt_for_body_7[i0] -> MemRef_A[1 + i0] };
48 ; AST-NEXT: for (int c0 = 0; c0 < N; c0 += 1)
49 ; AST-NEXT: Stmt_for_body_7(c0);
50 ; AST-NEXT: } else if (c == -1)
51 ; AST-NEXT: for (int c0 = 0; c0 < N; c0 += 1)
52 ; AST-NEXT: Stmt_for_body(c0);
55 ; AST-NEXT: { /* original code */ }
57 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
59 define void @f(i32* %A, i32 %c, i32 %N) {
64 switch i32 %c, label %sw.epilog [
69 sw.bb: ; preds = %entry
70 %tmp = sext i32 %N to i64
73 for.cond: ; preds = %for.inc, %sw.bb
74 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ %tmp, %sw.bb ]
75 %j.0 = phi i32 [ %N, %sw.bb ], [ %dec, %for.inc ]
76 %cmp = icmp sgt i64 %indvars.iv, 0
77 br i1 %cmp, label %for.body, label %for.end
79 for.body: ; preds = %for.cond
80 %sub = add nsw i32 %j.0, -1
81 %idxprom = sext i32 %sub to i64
82 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
83 %tmp6 = load i32, i32* %arrayidx, align 4
84 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
85 %tmp7 = load i32, i32* %arrayidx2, align 4
86 %add = add nsw i32 %tmp7, %tmp6
87 store i32 %add, i32* %arrayidx2, align 4
90 for.inc: ; preds = %for.body
91 %dec = add nsw i32 %j.0, -1
92 %indvars.iv.next = add nsw i64 %indvars.iv, -1
95 for.end: ; preds = %for.cond
98 sw.bb.3: ; preds = %entry
99 %tmp8 = sext i32 %N to i64
102 for.cond.5: ; preds = %for.inc.14, %sw.bb.3
103 %indvars.iv3 = phi i64 [ %indvars.iv.next4, %for.inc.14 ], [ 1, %sw.bb.3 ]
104 %cmp6 = icmp sgt i64 %indvars.iv3, %tmp8
105 br i1 %cmp6, label %for.end.15, label %for.body.7
107 for.body.7: ; preds = %for.cond.5
108 %tmp9 = add nsw i64 %indvars.iv3, -1
109 %arrayidx10 = getelementptr inbounds i32, i32* %A, i64 %tmp9
110 %tmp10 = load i32, i32* %arrayidx10, align 4
111 %arrayidx12 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv3
112 %tmp11 = load i32, i32* %arrayidx12, align 4
113 %add13 = add nsw i32 %tmp11, %tmp10
114 store i32 %add13, i32* %arrayidx12, align 4
117 for.inc.14: ; preds = %for.body.7
118 %indvars.iv.next4 = add nuw nsw i64 %indvars.iv3, 1
121 for.end.15: ; preds = %for.cond.5
124 sw.epilog: ; preds = %for.end.15, %for.end, %entry