1 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-scops -analyze < %s | FileCheck %s
3 ; void foo(float A[][20][30], long n, long m, long p) {
4 ; for (long i = 0; i < n; i++)
5 ; for (long j = 0; j < m; j++)
6 ; for (long k = 0; k < p; k++)
7 ; A[i][j][k] = i + j + k;
10 ; For the above code we want to assume that all memory accesses are within the
11 ; bounds of the array A. In C (and LLVM-IR) this is not required, such that out
12 ; of bounds accesses are valid. However, as such accesses are uncommon, cause
13 ; complicated dependence pattern and as a result make dependence analysis more
14 ; costly and may prevent or hinder useful program transformations, we assume
15 ; absence of out-of-bound accesses. To do so we derive the set of parameter
16 ; values for which our assumption holds.
18 ; CHECK: Assumed Context
19 ; CHECK-NEXT: [n, m, p] -> { : p <= 30 and m <= 20 }
21 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
23 define void @foo([20 x [30 x float]]* %A, i64 %n, i64 %m, i64 %p) {
27 for.cond: ; preds = %for.inc13, %entry
28 %i.0 = phi i64 [ 0, %entry ], [ %inc14, %for.inc13 ]
29 %cmp = icmp slt i64 %i.0, %n
30 br i1 %cmp, label %for.body, label %for.end15
32 for.body: ; preds = %for.cond
35 for.cond1: ; preds = %for.inc10, %for.body
36 %j.0 = phi i64 [ 0, %for.body ], [ %inc11, %for.inc10 ]
37 %cmp2 = icmp slt i64 %j.0, %m
38 br i1 %cmp2, label %for.body3, label %for.end12
40 for.body3: ; preds = %for.cond1
43 for.cond4: ; preds = %for.inc, %for.body3
44 %k.0 = phi i64 [ 0, %for.body3 ], [ %inc, %for.inc ]
45 %cmp5 = icmp slt i64 %k.0, %p
46 br i1 %cmp5, label %for.body6, label %for.end
48 for.body6: ; preds = %for.cond4
49 %add = add nsw i64 %i.0, %j.0
50 %add7 = add nsw i64 %add, %k.0
51 %conv = sitofp i64 %add7 to float
52 %arrayidx9 = getelementptr inbounds [20 x [30 x float]], [20 x [30 x float]]* %A, i64 %i.0, i64 %j.0, i64 %k.0
53 store float %conv, float* %arrayidx9, align 4
56 for.inc: ; preds = %for.body6
57 %inc = add nsw i64 %k.0, 1
60 for.end: ; preds = %for.cond4
63 for.inc10: ; preds = %for.end
64 %inc11 = add nsw i64 %j.0, 1
67 for.end12: ; preds = %for.cond1
70 for.inc13: ; preds = %for.end12
71 %inc14 = add nsw i64 %i.0, 1
74 for.end15: ; preds = %for.cond