• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-scops -polly-delinearize=false -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-scops -polly-delinearize=false -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
3; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s --check-prefix=DELIN
4; RUN: opt %loadPolly -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=DELIN
5; RUN: opt %loadPolly -polly-function-scops -polly-delinearize=false -analyze < %s | FileCheck %s
6; RUN: opt %loadPolly -polly-function-scops -polly-delinearize=false -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
7; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s --check-prefix=DELIN
8; RUN: opt %loadPolly -polly-function-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=DELIN
9
10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11
12; void single-and-multi-dimensional-array(long n,float X[n][n]) {
13;  for (long i1 = 0; i1 < n; i1++)
14;    X[i1][0] = 1;
15;
16;  for (long i2 = 0; i2 < n; i2++)
17;    X[n-1][i2] = 1;
18; }
19;
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.
23
24; CHECK-NOT: Stmt_for_i_1
25
26; NONAFFINE:      p0: %n
27; NONAFFINE-NEXT: p1: ((-1 + %n) * %n)
28;
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] };
44; NONAFFINE-NEXT: }
45
46; DELIN:      Statements {
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] };
61; DELIN-NEXT: }
62
63define void @single-and-multi-dimensional-array(i64 %n, float* %X) {
64entry:
65  br label %for.i.1
66
67for.i.1:
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, float* %X, i64 %offset.1
71  store float 1.000000e+00, float* %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
75
76next:
77  br label %for.i.2
78
79for.i.2:
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, float* %X, i64 %offset.2.c
85  store float 1.000000e+00, float* %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
89
90exit:
91  ret void
92}
93