1 ; RUN: opt %loadPolly -polly-print-scops -polly-delinearize=false -disable-output < %s | FileCheck %s
2 ; RUN: opt %loadPolly -polly-print-scops -polly-delinearize=false -polly-allow-nonaffine -disable-output < %s | FileCheck %s --check-prefix=NONAFFINE
3 ; RUN: opt %loadPolly -polly-print-scops -disable-output < %s | FileCheck %s --check-prefix=DELIN
4 ; RUN: opt %loadPolly -polly-print-scops -polly-allow-nonaffine -disable-output < %s | FileCheck %s --check-prefix=DELIN
5 ; RUN: opt %loadPolly -polly-print-function-scops -polly-delinearize=false -disable-output < %s | FileCheck %s
6 ; RUN: opt %loadPolly -polly-print-function-scops -polly-delinearize=false -polly-allow-nonaffine -disable-output < %s | FileCheck %s --check-prefix=NONAFFINE
7 ; RUN: opt %loadPolly -polly-print-function-scops -disable-output < %s | FileCheck %s --check-prefix=DELIN
8 ; RUN: opt %loadPolly -polly-print-function-scops -polly-allow-nonaffine -disable-output < %s | FileCheck %s --check-prefix=DELIN
10 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
12 ; void single-and-multi-dimensional-array(long n,float X[n][n]) {
13 ; for (long i1 = 0; i1 < n; i1++)
16 ; for (long i2 = 0; i2 < n; i2++)
20 ; In previous versions of Polly, the second access was detected as single
21 ; dimensional access whereas the first one was detected as multi-dimensional.
22 ; This test case checks that we now consistently delinearize the array accesses.
24 ; CHECK-NOT: Stmt_for_i_1
27 ; NONAFFINE-NEXT: p1: ((-1 + %n) * %n)
29 ; NONAFFINE: Statements {
30 ; NONAFFINE-NEXT: Stmt_for_i_1
31 ; NONAFFINE-NEXT: Domain :=
32 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_1[i0] : 0 <= i0 < n };
33 ; NONAFFINE-NEXT: Schedule :=
34 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_1[i0] -> [0, i0] };
35 ; NONAFFINE-NEXT: MayWriteAccess := [Reduction Type: NONE] [Scalar: 0]
36 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_1[i0] -> MemRef_X[o0] };
37 ; NONAFFINE-NEXT: Stmt_for_i_2
38 ; NONAFFINE-NEXT: Domain :=
39 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_2[i0] : 0 <= i0 < n };
40 ; NONAFFINE-NEXT: Schedule :=
41 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_2[i0] -> [1, i0] };
42 ; NONAFFINE-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
43 ; NONAFFINE-NEXT: [n, p_1] -> { Stmt_for_i_2[i0] -> MemRef_X[p_1 + i0] };
47 ; DELIN-NEXT: Stmt_for_i_1
48 ; DELIN-NEXT: Domain :=
49 ; DELIN-NEXT: [n] -> { Stmt_for_i_1[i0] : 0 <= i0 < n };
50 ; DELIN-NEXT: Schedule :=
51 ; DELIN-NEXT: [n] -> { Stmt_for_i_1[i0] -> [0, i0] };
52 ; DELIN-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
53 ; DELIN-NEXT: [n] -> { Stmt_for_i_1[i0] -> MemRef_X[i0, 0] };
54 ; DELIN-NEXT: Stmt_for_i_2
55 ; DELIN-NEXT: Domain :=
56 ; DELIN-NEXT: [n] -> { Stmt_for_i_2[i0] : 0 <= i0 < n };
57 ; DELIN-NEXT: Schedule :=
58 ; DELIN-NEXT: [n] -> { Stmt_for_i_2[i0] -> [1, i0] };
59 ; DELIN-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
60 ; DELIN-NEXT: [n] -> { Stmt_for_i_2[i0] -> MemRef_X[-1 + n, i0] };
63 define void @single-and-multi-dimensional-array(i64 %n, ptr %X) {
68 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %for.i.1 ]
69 %offset.1 = mul i64 %n, %indvar.1
70 %arrayidx.1 = getelementptr float, ptr %X, i64 %offset.1
71 store float 1.000000e+00, ptr %arrayidx.1
72 %indvar.next.1 = add nsw i64 %indvar.1, 1
73 %exitcond.1 = icmp ne i64 %indvar.next.1, %n
74 br i1 %exitcond.1, label %for.i.1, label %next
80 %indvar.2 = phi i64 [ 0, %next ], [ %indvar.next.2, %for.i.2 ]
81 %offset.2.a = add i64 %n, -1
82 %offset.2.b = mul i64 %n, %offset.2.a
83 %offset.2.c = add i64 %offset.2.b, %indvar.2
84 %arrayidx.2 = getelementptr float, ptr %X, i64 %offset.2.c
85 store float 1.000000e+00, ptr %arrayidx.2
86 %indvar.next.2 = add nsw i64 %indvar.2, 1
87 %exitcond.2 = icmp ne i64 %indvar.next.2, %n
88 br i1 %exitcond.2, label %for.i.2, label %exit