1 ; RUN: opt %loadPolly -polly-print-scops -disable-output < %s | FileCheck %s
2 ; RUN: opt %loadPolly -polly-print-ast -disable-output < %s | FileCheck %s --check-prefix=AST
4 ; void f(int *A, int N) {
5 ; for (int i = 0; i < N; i++)
21 ; CHECK-NEXT: Stmt_sw_bb
22 ; CHECK-NEXT: Domain :=
23 ; CHECK-NEXT: [N] -> { Stmt_sw_bb[i0] : (i0) mod 4 = 0 and 0 <= i0 < N };
24 ; CHECK-NEXT: Schedule :=
25 ; CHECK-NEXT: [N] -> { Stmt_sw_bb[i0] -> [i0, 2] };
26 ; CHECK-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0]
27 ; CHECK-NEXT: [N] -> { Stmt_sw_bb[i0] -> MemRef_A[i0] };
28 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
29 ; CHECK-NEXT: [N] -> { Stmt_sw_bb[i0] -> MemRef_A[i0] };
30 ; CHECK-NEXT: Stmt_sw_bb_1
31 ; CHECK-NEXT: Domain :=
32 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_1[i0] : 0 <= i0 < N and 4*floor((i0)/4) >= -1 + i0 };
33 ; CHECK-NEXT: Schedule :=
34 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_1[i0] -> [i0, 3] };
35 ; CHECK-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0]
36 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_1[i0] -> MemRef_A[i0] };
37 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
38 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_1[i0] -> MemRef_A[i0] };
39 ; CHECK-NEXT: Stmt_sw_bb_5
40 ; CHECK-NEXT: Domain :=
41 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_5[i0] : (2 + i0) mod 4 = 0 and 2 <= i0 < N };
42 ; CHECK-NEXT: Schedule :=
43 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_5[i0] -> [i0, 0] };
44 ; CHECK-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0]
45 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_5[i0] -> MemRef_A[i0] };
46 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
47 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_5[i0] -> MemRef_A[i0] };
48 ; CHECK-NEXT: Stmt_sw_bb_9
49 ; CHECK-NEXT: Domain :=
50 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_9[i0] : 0 <= i0 < N and 4*floor((i0)/4) <= -2 + i0 };
51 ; CHECK-NEXT: Schedule :=
52 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_9[i0] -> [i0, 1] };
53 ; CHECK-NEXT: ReadAccess := [Reduction Type: +] [Scalar: 0]
54 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_9[i0] -> MemRef_A[i0] };
55 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
56 ; CHECK-NEXT: [N] -> { Stmt_sw_bb_9[i0] -> MemRef_A[i0] };
61 ; AST: for (int c0 = 0; c0 < N; c0 += 1) {
62 ; AST-NEXT: if ((c0 + 2) % 4 == 0)
63 ; AST-NEXT: Stmt_sw_bb_5(c0);
64 ; AST-NEXT: if (c0 % 4 >= 2) {
65 ; AST-NEXT: Stmt_sw_bb_9(c0);
67 ; AST-NEXT: if (c0 % 4 == 0)
68 ; AST-NEXT: Stmt_sw_bb(c0);
69 ; AST-NEXT: Stmt_sw_bb_1(c0);
74 ; AST-NEXT: { /* original code */ }
76 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
78 define void @f(ptr %A, i32 %N) {
80 %tmp = sext i32 %N to i64
83 for.cond: ; preds = %for.inc, %entry
84 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
85 %cmp = icmp slt i64 %indvars.iv, %tmp
86 br i1 %cmp, label %for.body, label %for.end
88 for.body: ; preds = %for.cond
89 %tmp1 = trunc i64 %indvars.iv to i32
90 %rem = srem i32 %tmp1, 4
91 switch i32 %rem, label %sw.epilog [
98 sw.bb: ; preds = %for.body
99 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
100 %tmp2 = load i32, ptr %arrayidx, align 4
101 %add = add nsw i32 %tmp2, 1
102 store i32 %add, ptr %arrayidx, align 4
105 sw.bb.1: ; preds = %sw.bb, %for.body
106 %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
107 %tmp3 = load i32, ptr %arrayidx3, align 4
108 %add4 = add nsw i32 %tmp3, 2
109 store i32 %add4, ptr %arrayidx3, align 4
112 sw.bb.5: ; preds = %for.body
113 %arrayidx7 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
114 %tmp4 = load i32, ptr %arrayidx7, align 4
115 %add8 = add nsw i32 %tmp4, 3
116 store i32 %add8, ptr %arrayidx7, align 4
119 sw.bb.9: ; preds = %sw.bb.5, %for.body
120 %arrayidx11 = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
121 %tmp5 = load i32, ptr %arrayidx11, align 4
122 %add12 = add nsw i32 %tmp5, 4
123 store i32 %add12, ptr %arrayidx11, align 4
126 sw.epilog: ; preds = %sw.bb.9, %sw.bb.1, %for.body
129 for.inc: ; preds = %sw.epilog
130 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
133 for.end: ; preds = %for.cond