1 ; RUN: opt %loadPolly -polly-detect-unprofitable -basicaa -polly-dependences -analyze < %s | FileCheck %s
3 ; CHECK: RAW dependences:
4 ; CHECK-DAG: Stmt_S0[i0] -> Stmt_S1[o0, i0 - o0] : i0 <= 1023 and o0 >= 0 and o0 <= i0
5 ; CHECK-DAG: Stmt_S1[i0, i1] -> Stmt_S2[-1 + i0 + i1] : i1 <= 1023 and i1 >= 0 and i1 >= 1 - i0 and i0 >= 0 and i0 <= 1023 and i1 <= 1024 - i0
6 ; CHECK: WAR dependences:
7 ; CHECK-DAG: Stmt_S2[i0] -> Stmt_S2[1 + i0] : i0 <= 1022 and i0 >= 0
8 ; CHECK-DAG: Stmt_S1[i0, i1] -> Stmt_S2[i0 + i1] : i1 <= 1023 - i0 and i1 >= 0 and i1 >= 1 - i0 and i0 >= 0 }
9 ; CHECK: WAW dependences:
10 ; CHECK-DAG: Stmt_S0[i0] -> Stmt_S1[o0, i0 - o0] : i0 <= 1023 and o0 >= 0 and o0 <= i0
11 ; CHECK-DAG: Stmt_S1[0, 0] -> Stmt_S2[0]
12 ; CHECK: Reduction dependences:
13 ; CHECK-DAG: Stmt_S1[i0, i1] -> Stmt_S1[1 + i0, -1 + i1] : i0 <= 1022 and i0 >= 0 and i1 <= 1023 and i1 >= 1
16 ; for (int i = 0; i < 1024; i++)
18 ; for (int i = 0; i < 1024; i++)
19 ; for (int j = 0; j < 1024; j++)
20 ; S1: sum[i + j] += i;
21 ; for (int i = 0; i < 1024; i++)
22 ; S2: sum[i] = sum[i + 1] * 3;
24 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
26 define void @f(i32* %sum) {
30 for.cond: ; preds = %for.inc, %entry
31 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
32 %exitcond3 = icmp ne i32 %i.0, 1024
33 br i1 %exitcond3, label %for.body, label %for.end
35 for.body: ; preds = %for.cond
38 S0: ; preds = %for.body
39 %arrayidx = getelementptr inbounds i32, i32* %sum, i32 %i.0
40 store i32 0, i32* %arrayidx, align 4
43 for.inc: ; preds = %S0
44 %inc = add nsw i32 %i.0, 1
47 for.end: ; preds = %for.cond
50 for.cond2: ; preds = %for.inc13, %for.end
51 %i1.0 = phi i32 [ 0, %for.end ], [ %inc14, %for.inc13 ]
52 %exitcond2 = icmp ne i32 %i1.0, 1024
53 br i1 %exitcond2, label %for.body4, label %for.end15
55 for.body4: ; preds = %for.cond2
58 for.cond5: ; preds = %for.inc10, %for.body4
59 %j.0 = phi i32 [ 0, %for.body4 ], [ %inc11, %for.inc10 ]
60 %exitcond1 = icmp ne i32 %j.0, 1024
61 br i1 %exitcond1, label %for.body7, label %for.end12
63 for.body7: ; preds = %for.cond5
66 S1: ; preds = %for.body7
67 %add = add nsw i32 %i1.0, %j.0
68 %arrayidx8 = getelementptr inbounds i32, i32* %sum, i32 %add
69 %tmp = load i32* %arrayidx8, align 4
70 %add9 = add nsw i32 %tmp, %i1.0
71 store i32 %add9, i32* %arrayidx8, align 4
74 for.inc10: ; preds = %S1
75 %inc11 = add nsw i32 %j.0, 1
78 for.end12: ; preds = %for.cond5
81 for.inc13: ; preds = %for.end12
82 %inc14 = add nsw i32 %i1.0, 1
85 for.end15: ; preds = %for.cond2
88 for.cond17: ; preds = %for.inc23, %for.end15
89 %i16.0 = phi i32 [ 0, %for.end15 ], [ %inc24, %for.inc23 ]
90 %exitcond = icmp ne i32 %i16.0, 1024
91 br i1 %exitcond, label %for.body19, label %for.end25
93 for.body19: ; preds = %for.cond17
96 S2: ; preds = %for.body19
97 %add20 = add nsw i32 %i16.0, 1
98 %arrayidx21 = getelementptr inbounds i32, i32* %sum, i32 %add20
99 %tmp4 = load i32* %arrayidx21, align 4
100 %mul = mul nsw i32 %tmp4, 3
101 %arrayidx22 = getelementptr inbounds i32, i32* %sum, i32 %i16.0
102 store i32 %mul, i32* %arrayidx22, align 4
105 for.inc23: ; preds = %S2
106 %inc24 = add nsw i32 %i16.0, 1
109 for.end25: ; preds = %for.cond17