• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-dependences -analyze -basic-aa < %s | FileCheck %s
2;
3; CHECK:      Reduction dependences:
4; CHECK-NEXT:     { Stmt_for_inc[i0, i1] -> Stmt_for_inc[i0, 1 + i1] : 0 <= i0 <= 99 and 0 <= i1 <= 98 }
5;
6; int f(int * __restrict__ A) {
7;   int i, j, sum = 0;
8;   for (k = 0; k < 37; k = g(k)) {
9;     for (i = 0; i < 100; i++) {
10;       sum *= 2;
11;       for (j = 0; j < 100; j++) {
12;         sum += A[i+j];
13;       }
14;     }
15;   }
16;   return sum;
17; }
18target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
19
20declare i64 @g(i64)
21
22define i32 @f(i32* noalias %A) {
23entry:
24  %sum.04.reg2mem = alloca i32
25  %sum.12.reg2mem = alloca i32
26  br label %entry.split
27
28entry.split:                                      ; preds = %entry
29  store i32 0, i32* %sum.04.reg2mem
30  br label %for.body_outer_split
31
32for.body_outer_split:                             ; preds = %entry.split, %for.inc5
33  %indvars.ivK = phi i64 [ 0, %entry.split ], [ %incK, %for.bos2 ]
34  br label %for.body_outer
35
36for.body_outer:                                   ; preds = %for.body_outer_split
37  %incK = call i64 @g(i64 %indvars.ivK)
38  %exitcondK = icmp eq i64 %incK, 100
39  br i1 %exitcondK, label %for.end7, label %for.body
40
41for.body:                                         ; preds = %for.inc5, %for.body_outer
42  %indvars.iv23 = phi i64 [ 0, %for.body_outer ], [ %3, %for.inc5 ]
43  %sum.04.reload = load i32, i32* %sum.04.reg2mem
44  %mul = shl nsw i32 %sum.04.reload, 1
45  store i32 %mul, i32* %sum.12.reg2mem
46  br label %for.inc
47
48for.inc:                                          ; preds = %for.inc, %for.body
49  %indvars.iv1 = phi i64 [ 0, %for.body ], [ %1, %for.inc ]
50  %sum.12.reload = load i32, i32* %sum.12.reg2mem
51  %0 = add i64 %indvars.iv23, %indvars.iv1
52  %arrayidx = getelementptr i32, i32* %A, i64 %0
53  %tmp5 = load i32, i32* %arrayidx, align 4
54  %add4 = add nsw i32 %tmp5, %sum.12.reload
55  %1 = add nuw nsw i64 %indvars.iv1, 1
56  %exitcond1 = icmp eq i64 %1, 100
57  store i32 %add4, i32* %sum.12.reg2mem
58  br i1 %exitcond1, label %for.inc5, label %for.inc
59
60for.inc5:                                         ; preds = %for.inc
61  %2 = load i32, i32* %sum.12.reg2mem
62  %3 = add nuw nsw i64 %indvars.iv23, 1
63  %exitcond2 = icmp eq i64 %3, 100
64  store i32 %2, i32* %sum.04.reg2mem
65  br i1 %exitcond2, label %for.bos2, label %for.body
66
67for.bos2:
68  br label %for.body_outer_split
69
70for.end7:                                         ; preds = %for.inc5
71  %4 = load i32, i32* %sum.04.reg2mem
72  ret i32 %4
73}
74