1; RUN: opt %loadPolly -polly-scops -analyze \
2; RUN:  -polly-precise-fold-accesses  < %s | FileCheck %s
3;
4;    void foo(long n, long m, float A[][n][m]) {
5;      for (long i = 0; i < 100; i++)
6;        for (long j = 0; j < n; j++)
7;          for (long k = 0; k < m; k++)
8;            A[i][j][k] += A[i][n - j - 1][m - k - 1];
9;    }
10;
11; Verify that the parameter in the subscript expression is correctly
12; recovered.
13;
14; CHECK: Assumed Context:
15; CHECK-NEXT: [n, m] -> {  :  }
16; CHECK: ReadAccess :=       [Reduction Type: NONE] [Scalar: 0]
17; CHECK-NEXT: [n, m] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[i0, -1 + n - i1, -1 + m - i2] };
18;
19target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20
21define void @foo(i64 %n, i64 %m, float* %A) {
22entry:
23  br label %for.cond
24
25for.cond:                                         ; preds = %for.inc18, %entry
26  %i.0 = phi i64 [ 0, %entry ], [ %inc19, %for.inc18 ]
27  %exitcond = icmp ne i64 %i.0, 100
28  br i1 %exitcond, label %for.body, label %for.end20
29
30for.body:                                         ; preds = %for.cond
31  br label %for.cond1
32
33for.cond1:                                        ; preds = %for.inc15, %for.body
34  %j.0 = phi i64 [ 0, %for.body ], [ %inc16, %for.inc15 ]
35  %cmp2 = icmp slt i64 %j.0, %n
36  br i1 %cmp2, label %for.body3, label %for.end17
37
38for.body3:                                        ; preds = %for.cond1
39  br label %for.cond4
40
41for.cond4:                                        ; preds = %for.inc, %for.body3
42  %k.0 = phi i64 [ 0, %for.body3 ], [ %inc, %for.inc ]
43  %cmp5 = icmp slt i64 %k.0, %m
44  br i1 %cmp5, label %for.body6, label %for.end
45
46for.body6:                                        ; preds = %for.cond4
47  %sub = sub nsw i64 %m, %k.0
48  %sub7 = add nsw i64 %sub, -1
49  %sub8 = sub nsw i64 %n, %j.0
50  %sub9 = add nsw i64 %sub8, -1
51  %tmp = mul nuw i64 %n, %m
52  %tmp1 = mul nsw i64 %i.0, %tmp
53  %tmp2 = mul nsw i64 %sub9, %m
54  %arrayidx.sum = add i64 %tmp1, %tmp2
55  %arrayidx10.sum = add i64 %arrayidx.sum, %sub7
56  %arrayidx11 = getelementptr inbounds float, float* %A, i64 %arrayidx10.sum
57  %tmp3 = load float, float* %arrayidx11, align 4
58  %tmp4 = mul nuw i64 %n, %m
59  %tmp5 = mul nsw i64 %i.0, %tmp4
60  %tmp6 = mul nsw i64 %j.0, %m
61  %arrayidx12.sum = add i64 %tmp5, %tmp6
62  %arrayidx13.sum = add i64 %arrayidx12.sum, %k.0
63  %arrayidx14 = getelementptr inbounds float, float* %A, i64 %arrayidx13.sum
64  %tmp7 = load float, float* %arrayidx14, align 4
65  %add = fadd float %tmp7, %tmp3
66  store float %add, float* %arrayidx14, align 4
67  br label %for.inc
68
69for.inc:                                          ; preds = %for.body6
70  %inc = add nuw nsw i64 %k.0, 1
71  br label %for.cond4
72
73for.end:                                          ; preds = %for.cond4
74  br label %for.inc15
75
76for.inc15:                                        ; preds = %for.end
77  %inc16 = add nuw nsw i64 %j.0, 1
78  br label %for.cond1
79
80for.end17:                                        ; preds = %for.cond1
81  br label %for.inc18
82
83for.inc18:                                        ; preds = %for.end17
84  %inc19 = add nuw nsw i64 %i.0, 1
85  br label %for.cond
86
87for.end20:                                        ; preds = %for.cond
88  ret void
89}
90