1 ; RUN: opt %loadPolly -polly-ast -analyze -polly-precise-inbounds < %s \
2 ; RUN: -polly-precise-fold-accesses \
5 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 ; void foo(long n, long m, int o, double A[n][m], long p, long q) {
10 ; for (long i = 0; i < n; i++)
11 ; for (long j = 0; j < m; j++)
14 ; for (long i = 0; i < n; i++)
15 ; for (long j = 0; j < m; j++)
16 ; A[i+p][j+q-100] = 1.0;
19 ; This test case is meant to verify that the run-time condition generated
20 ; for the delinearization is simplified such that conditions that would not
21 ; cause any code to be executed are not generated.
23 ; CHECK: if (((o >= 1 && q <= 0 && m + q >= 0) || (o <= 0 && m + q >= 100 && q <= 100)) && 0 == ((m >= 1 && n + p >= 9223372036854775809) || (o <= 0 && n >= 1 && m + q >= 9223372036854775909) || (o <= 0 && m >= 1 && n >= 1 && q <= -9223372036854775709)))
25 ; CHECK: if (o <= 0) {
26 ; CHECK: for (int c0 = 0; c0 < n; c0 += 1)
27 ; CHECK: for (int c1 = 0; c1 < m; c1 += 1)
28 ; CHECK: Stmt_for_j_1(c0, c1);
30 ; CHECK: for (int c0 = 0; c0 < n; c0 += 1)
31 ; CHECK: for (int c1 = 0; c1 < m; c1 += 1)
32 ; CHECK: Stmt_for_j(c0, c1);
35 ; CHECK: { /* original code */ }
37 define void @foo(i64 %n, i64 %m, i64 %o, double* %A, i64 %p, i64 %q) {
42 %cmp = icmp sgt i64 %o, 0
43 br i1 %cmp, label %for.i, label %for.i.1
46 %i = phi i64 [ 0, %cond ], [ %i.inc, %for.i.inc ]
50 %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j.inc ]
51 %offset0 = add nsw i64 %i, %p
52 %subscript0 = mul i64 %offset0, %m
53 %offset1 = add nsw i64 %j, %q
54 %subscript1 = add i64 %offset1, %subscript0
55 %idx = getelementptr inbounds double, double* %A, i64 %subscript1
56 store double 1.0, double* %idx
60 %j.inc = add nsw i64 %j, 1
61 %j.exitcond = icmp eq i64 %j.inc, %m
62 br i1 %j.exitcond, label %for.i.inc, label %for.j
65 %i.inc = add nsw i64 %i, 1
66 %i.exitcond = icmp eq i64 %i.inc, %n
67 br i1 %i.exitcond, label %end, label %for.i
70 %i.1 = phi i64 [ 0, %cond ], [ %i.inc.1, %for.i.inc.1 ]
74 %j.1 = phi i64 [ 0, %for.i.1 ], [ %j.inc.1, %for.j.inc.1 ]
75 %offset0.1 = add nsw i64 %i.1, %p
76 %subscript0.1 = mul i64 %offset0.1, %m
77 %offset1.1 = add nsw i64 %j.1, %q
78 %subscript1.1 = add i64 %offset1.1, %subscript0.1
79 %subscript1.2 = sub i64 %subscript1.1, 100
80 %idx.1 = getelementptr inbounds double, double* %A, i64 %subscript1.2
81 store double 1.0, double* %idx.1
85 %j.inc.1 = add nsw i64 %j.1, 1
86 %j.exitcond.1 = icmp eq i64 %j.inc.1, %m
87 br i1 %j.exitcond.1, label %for.i.inc.1, label %for.j.1
90 %i.inc.1 = add nsw i64 %i.1, 1
91 %i.exitcond.1 = icmp eq i64 %i.inc.1, %n
92 br i1 %i.exitcond.1, label %end, label %for.i.1