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