1 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -analyze < %s | FileCheck %s
2 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=NONAFFINE
3 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -polly-delinearize -analyze < %s | FileCheck %s --check-prefix=DELIN
4 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -polly-delinearize -polly-allow-nonaffine -analyze < %s | FileCheck %s --check-prefix=DELIN
6 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
8 ; void single-and-multi-dimensional-array(long n,float X[n][n]) {
9 ; for (long i1 = 0; i1 < n; i1++)
12 ; for (long i2 = 0; i2 < n; i2++)
16 ; In previous versions of Polly, the second access was detected as single
17 ; dimensional access whereas the first one was detected as multi-dimensional.
18 ; This test case checks that we now consistently delinearize the array accesses.
20 ; CHECK-NOT: Stmt_for_i_1
23 ; NONAFFINE: p1: (4 * (-1 + %n) * %n)
24 ; NONAFFINE: Statements {
25 ; NONAFFINE: Stmt_for_i_1
26 ; NONAFFINE: MayWriteAccess := [Reduction Type: NONE]
27 ; NONAFFINE: [n, p_1] -> { Stmt_for_i_1[i0] -> MemRef_X[o0] : o0 >= -2305843009213693952 and o0 <= 2305843009213693949 };
28 ; NONAFFINE: Stmt_for_i_2
29 ; NONAFFINE: MustWriteAccess := [Reduction Type: NONE]
30 ; NONAFFINE: [n, p_1] -> { Stmt_for_i_2[i0] -> MemRef_X[o0] : 4o0 = p_1 + 4i0 };
33 ; DELIN: MustWriteAccess :=
34 ; DELIN: [n] -> { Stmt_for_i_1[i0] -> MemRef_X[i0, 0] };
36 ; DELIN: MustWriteAccess :=
37 ; DELIN: [n] -> { Stmt_for_i_2[i0] -> MemRef_X[-1 + n, i0] };
39 define void @single-and-multi-dimensional-array(i64 %n, float* %X) {
44 %indvar.1 = phi i64 [ 0, %entry ], [ %indvar.next.1, %for.i.1 ]
45 %offset.1 = mul i64 %n, %indvar.1
46 %arrayidx.1 = getelementptr float, float* %X, i64 %offset.1
47 store float 1.000000e+00, float* %arrayidx.1
48 %indvar.next.1 = add nsw i64 %indvar.1, 1
49 %exitcond.1 = icmp ne i64 %indvar.next.1, %n
50 br i1 %exitcond.1, label %for.i.1, label %next
56 %indvar.2 = phi i64 [ 0, %next ], [ %indvar.next.2, %for.i.2 ]
57 %offset.2.a = add i64 %n, -1
58 %offset.2.b = mul i64 %n, %offset.2.a
59 %offset.2.c = add i64 %offset.2.b, %indvar.2
60 %arrayidx.2 = getelementptr float, float* %X, i64 %offset.2.c
61 store float 1.000000e+00, float* %arrayidx.2
62 %indvar.next.2 = add nsw i64 %indvar.2, 1
63 %exitcond.2 = icmp ne i64 %indvar.next.2, %n
64 br i1 %exitcond.2, label %for.i.2, label %exit