• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -analyze -polly-scops < %s | FileCheck %s
2; RUN: opt %loadPolly -analyze -polly-function-scops < %s | FileCheck %s
3;
4; Check that the constant part of the N * M * 4 expression is not part of the
5; parameter but explicit in the access function. This can avoid existentially
6; quantified variables, e.g., when computing the stride.
7;
8; CHECK: p1: (%N * %M)
9; CHECK: [N, p_1] -> { Stmt_for_body[i0] -> MemRef_A[4p_1 + i0] };
10;
11;    void f(int *A, int N, int M) {
12;      for (int i = 0; i < N; i++)
13;        A[i + N * M * 4] = i;
14;    }
15;
16target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
17
18define void @f(i32* %A, i32 %N, i32 %M) {
19entry:
20  %tmp = sext i32 %N to i64
21  br label %for.cond
22
23for.cond:                                         ; preds = %for.inc, %entry
24  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
25  %cmp = icmp slt i64 %indvars.iv, %tmp
26  br i1 %cmp, label %for.body, label %for.end
27
28for.body:                                         ; preds = %for.cond
29  %mul = mul nsw i32 %N, %M
30  %mul2 = mul nsw i32 %mul, 4
31  %tmp2 = sext i32 %mul2 to i64
32  %tmp3 = add nsw i64 %indvars.iv, %tmp2
33  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %tmp3
34  %tmp4 = trunc i64 %indvars.iv to i32
35  store i32 %tmp4, i32* %arrayidx, align 4
36  br label %for.inc
37
38for.inc:                                          ; preds = %for.body
39  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
40  br label %for.cond
41
42for.end:                                          ; preds = %for.cond
43  ret void
44}
45