From 1ca3c6e1a76379d8b8dc714395167bae0f1a09b1 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 8 Sep 2012 14:56:40 +0200 Subject: [PATCH] isl_aff_ceil: compute ceil(e/m) as floor((e + m - 1)/m) The original implementation would compute ceil(e/m) as -floor(-e/m). Although both are correct, floor((e + m - 1)/m) is probably less surprising. Signed-off-by: Sven Verdoolaege --- isl_aff.c | 19 ++++++++++++++++--- test_inputs/codegen/cloog/classen2.c | 2 +- test_inputs/codegen/cloog/jacobi-shared.c | 2 +- test_inputs/codegen/cloog/levenshtein-1-2-3.c | 2 +- test_inputs/codegen/cloog/nul_complex1.c | 2 +- test_inputs/codegen/cloog/otl.c | 14 +++++++------- test_inputs/codegen/cloog/pouchet.c | 2 +- test_inputs/codegen/cloog/reservoir-bastoul3.c | 2 +- test_inputs/codegen/cloog/reservoir-cholesky2.c | 6 +++--- test_inputs/codegen/cloog/reservoir-lim-lam3.c | 22 +++++++++++----------- test_inputs/codegen/cloog/reservoir-liu-zhuge1.c | 4 ++-- test_inputs/codegen/cloog/reservoir-pingali5.c | 8 ++++---- test_inputs/codegen/cloog/vivien.c | 4 ++-- test_inputs/codegen/cloog/vivien2.c | 4 ++-- test_inputs/codegen/omega/floor_bound-0.c | 2 +- test_inputs/codegen/omega/floor_bound-1.c | 2 +- test_inputs/codegen/omega/hpf-0.c | 2 +- test_inputs/codegen/omega/iter8-0.c | 2 +- test_inputs/codegen/omega/lefur00-0.c | 10 +++++----- test_inputs/codegen/omega/lefur01-0.c | 10 +++++----- test_inputs/codegen/omega/lefur01-1.c | 10 +++++----- test_inputs/codegen/omega/lefur03-0.c | 14 +++++++------- test_inputs/codegen/omega/lefur04-0.c | 16 ++++++++-------- test_inputs/codegen/omega/m11-0.c | 2 +- test_inputs/codegen/omega/p.delft-0.c | 2 +- test_inputs/codegen/omega/stride6-0.c | 2 +- test_inputs/codegen/omega/substitution-1.c | 2 +- test_inputs/codegen/omega/ts1d-check0-0.c | 2 +- test_inputs/codegen/omega/ts1d-mp-i_ts-m_b-0.c | 14 +++++++------- test_inputs/codegen/stride5.c | 2 +- 30 files changed, 100 insertions(+), 87 deletions(-) rewrite test_inputs/codegen/cloog/otl.c (82%) rewrite test_inputs/codegen/cloog/reservoir-lim-lam3.c (67%) rewrite test_inputs/codegen/omega/lefur00-0.c (76%) rewrite test_inputs/codegen/omega/lefur01-0.c (76%) rewrite test_inputs/codegen/omega/lefur01-1.c (76%) rewrite test_inputs/codegen/omega/lefur03-0.c (62%) rewrite test_inputs/codegen/omega/lefur04-0.c (76%) diff --git a/isl_aff.c b/isl_aff.c index 79fd8d5b..c2e3f532 100644 --- a/isl_aff.c +++ b/isl_aff.c @@ -994,7 +994,13 @@ __isl_give isl_pw_aff *isl_pw_aff_mod(__isl_take isl_pw_aff *pwaff, isl_int m) /* Given f, return ceil(f). * If f is an integer expression, then just return f. - * Otherwise, create a new div d = [-f] and return the expression -d. + * Otherwise, let f be the expression + * + * e/m + * + * then return + * + * floor((e + m - 1)/m) */ __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff) { @@ -1004,9 +1010,16 @@ __isl_give isl_aff *isl_aff_ceil(__isl_take isl_aff *aff) if (isl_int_is_one(aff->v->el[0])) return aff; - aff = isl_aff_neg(aff); + aff = isl_aff_cow(aff); + if (!aff) + return NULL; + aff->v = isl_vec_cow(aff->v); + if (!aff->v) + return isl_aff_free(aff); + + isl_int_add(aff->v->el[1], aff->v->el[1], aff->v->el[0]); + isl_int_sub_ui(aff->v->el[1], aff->v->el[1], 1); aff = isl_aff_floor(aff); - aff = isl_aff_neg(aff); return aff; } diff --git a/test_inputs/codegen/cloog/classen2.c b/test_inputs/codegen/cloog/classen2.c index 314eb1c8..0b9ca0e8 100644 --- a/test_inputs/codegen/cloog/classen2.c +++ b/test_inputs/codegen/cloog/classen2.c @@ -1,4 +1,4 @@ for (int c0 = max(max(max(max(max(max(4, 10 * outerProcTileScatter1 - 2 * N + 2), 10 * outerProcTileScatter2 - N + 1), 5 * outerProcTileScatter2 + 1), 5 * outerTimeTileScatter), 5 * outerProcTileScatter1 + 5 * outerProcTileScatter2 - N), 5 * outerProcTileScatter1); c0 <= min(min(min(min(min(min(2 * M + 2 * N - 6, 5 * outerProcTileScatter2 + M + N), 5 * outerProcTileScatter1 + M + 2), 10 * outerProcTileScatter2 + N + 3), 10 * outerProcTileScatter1 + 4), 5 * outerTimeTileScatter + 4), 5 * outerProcTileScatter1 + 5 * outerProcTileScatter2 + 5); c0 += 1) - for (int c1 = max(max(max(max(-5 * outerProcTileScatter2 + c0 - 1, 5 * outerProcTileScatter1), 5 * outerProcTileScatter2 + 1), -M + c0 + 2), c0 - c0 / 2 + 2); c1 <= min(min(min(min(5 * outerProcTileScatter1 + 4, 5 * outerProcTileScatter2 + N + 2), c0), -5 * outerProcTileScatter2 + N + c0), N + c0 / 2 - 1); c1 += 1) + for (int c1 = max(max(max(max(-5 * outerProcTileScatter2 + c0 - 1, 5 * outerProcTileScatter1), 5 * outerProcTileScatter2 + 1), -M + c0 + 2), (c0 + 1) / 2 + 2); c1 <= min(min(min(min(5 * outerProcTileScatter1 + 4, 5 * outerProcTileScatter2 + N + 2), c0), -5 * outerProcTileScatter2 + N + c0), N + c0 / 2 - 1); c1 += 1) for (int c2 = max(max(5 * outerProcTileScatter2, -N + c1 + 2), c0 - c1 + 3); c2 <= min(min(5 * outerProcTileScatter2 + 4, N + c0 - c1), c1 - 1); c2 += 1) S1(c0 - c1 + 1, -c0 + c1 + c2 - 2, c1 - c2, c0, c1, c2); diff --git a/test_inputs/codegen/cloog/jacobi-shared.c b/test_inputs/codegen/cloog/jacobi-shared.c index 6314bc32..c671cf9e 100644 --- a/test_inputs/codegen/cloog/jacobi-shared.c +++ b/test_inputs/codegen/cloog/jacobi-shared.c @@ -1,3 +1,3 @@ if (2 * floord(h0 - 1, 2) + 1 == h0 && g2 + 29 >= (g2 - t1 + 32) % 32 && ((g2 - t1 + 32) % 32) + N >= g2 + 33) - for (int c0 = max(-((-t0 + 16) % 16) + 16, t0 - 16 * floord(g1 + t0 - 3, 16)); c0 <= min(32, N - g1 - 1); c0 += 16) + for (int c0 = max(((t0 + 15) % 16) + 1, ((g1 + t0 + 13) % 16) - g1 + 3); c0 <= min(32, N - g1 - 1); c0 += 16) S1(g1 + c0 - 1, ((t1 + 31) % 32) + g2); diff --git a/test_inputs/codegen/cloog/levenshtein-1-2-3.c b/test_inputs/codegen/cloog/levenshtein-1-2-3.c index 6929d18f..10fa2a39 100644 --- a/test_inputs/codegen/cloog/levenshtein-1-2-3.c +++ b/test_inputs/codegen/cloog/levenshtein-1-2-3.c @@ -17,7 +17,7 @@ S5(c0, (-N + c0) / 2); S8(c0, (-N + c0) / 2); } - for (int c1 = c0 - (N + c0 + 1) / 2 + 1; c1 < (N + c0 + 1) / 2; c1 += 1) { + for (int c1 = -N + (N + c0) / 2 + 1; c1 < (N + c0 + 1) / 2; c1 += 1) { S6(c0, c1); S8(c0, c1); } diff --git a/test_inputs/codegen/cloog/nul_complex1.c b/test_inputs/codegen/cloog/nul_complex1.c index 750e3314..6395f8a5 100644 --- a/test_inputs/codegen/cloog/nul_complex1.c +++ b/test_inputs/codegen/cloog/nul_complex1.c @@ -1,3 +1,3 @@ for (int c0 = 0; c0 <= 5 * n; c0 += 1) - for (int c1 = max(((n + c0) % 2) - n + c0, ((c0 + c0 / 3) % 2) + c0 - c0 / 3); c1 <= min(n + c0 - (n + c0 + 2) / 3, c0); c1 += 2) + for (int c1 = max(-((n + c0 + 1) % 2) - n + c0 + 1, 2 * floord(c0 - (c0 + 3) / 3, 2) + 2); c1 <= min(n + c0 - (n + c0 + 2) / 3, c0); c1 += 2) S1((-2 * c0 + 3 * c1) / 2, c0 - c1); diff --git a/test_inputs/codegen/cloog/otl.c b/test_inputs/codegen/cloog/otl.c dissimilarity index 82% index d0848ca1..b84006b9 100644 --- a/test_inputs/codegen/cloog/otl.c +++ b/test_inputs/codegen/cloog/otl.c @@ -1,7 +1,7 @@ -if (M >= 3 && N >= 4) - for (int c0 = 1; c0 < (2 * M + 2 * N - 2) / 5; c0 += 1) - for (int c1 = max(c0 - c0 / 2, c0 - (M + 2) / 5); c1 <= min(min((2 * N + 5 * c0 + 1) / 10, c0), (M + 2 * N) / 5 - 1); c1 += 1) - for (int c2 = max(max(max(max(c0 - (N + 5 * c0 + 2) / 10, c1 - (N + 1) / 5), c0 - c1 - 1), 0), c0 - (M + N - 1) / 5); c2 <= min(min(min(c0 - c1 + (N - 1) / 5 + 1, (N + 5 * c0 + 3) / 10), c1), (M + N - 2) / 5); c2 += 1) - for (int c3 = max(max(max(c1 + c2 - (N - 2) / 5 - 1, 2 * c2 - (N + 2) / 5), 2 * c1 - 2 * N / 5), c0); c3 <= min(min(min(min(min(c0 + 1, c1 + c2 + 1), c2 + (M + N) / 5), (2 * M + 2 * N - 1) / 5 - 1), c1 + (M - 2) / 5 + 1), 2 * c2 + (N - 2) / 5 + 1); c3 += 1) - for (int c4 = max(max(max(max(c1, c0 - c2), c3 - (M + 2) / 5), c0 - (M + 1) / 5), c3 - c3 / 2); c4 <= min(min(min(min(min(min(min(c0 - c2 + N / 5 + 1, -c2 + c3 + (N - 1) / 5 + 1), (2 * N + 5 * c0 + 3) / 10), (M + 2 * N + 1) / 5 - 1), (2 * N + 5 * c3 + 2) / 10), c2 + (N + 2) / 5), c1 + 1), c0); c4 += 1) - S1(c0, c1, c2, c3, c4, c2); +if (M >= 3 && N >= 4) + for (int c0 = 1; c0 < (2 * M + 2 * N - 2) / 5; c0 += 1) + for (int c1 = max((c0 + 1) / 2, c0 - (M + 2) / 5); c1 <= min(min((2 * N + 5 * c0 + 1) / 10, c0), (M + 2 * N) / 5 - 1); c1 += 1) + for (int c2 = max(max(max(max(floord(-N + 5 * c0 - 3, 10) + 1, c1 - (N + 6) / 5 + 1), c0 - c1 - 1), 0), c0 - (M + N + 4) / 5 + 1); c2 <= min(min(min(c0 - c1 + (N - 1) / 5 + 1, (N + 5 * c0 + 3) / 10), c1), (M + N - 2) / 5); c2 += 1) + for (int c3 = max(max(max(c1 + c2 - (N + 3) / 5, 2 * c2 - (N + 2) / 5), 2 * c1 - (2 * N + 5) / 5 + 1), c0); c3 <= min(min(min(min(min(c0 + 1, c1 + c2 + 1), c2 + (M + N) / 5), (2 * M + 2 * N - 1) / 5 - 1), c1 + (M - 2) / 5 + 1), 2 * c2 + (N - 2) / 5 + 1); c3 += 1) + for (int c4 = max(max(max(max(c1, c0 - c2), c3 - (M + 2) / 5), c0 - (M + 6) / 5 + 1), (c3 + 1) / 2); c4 <= min(min(min(min(min(min(min(c0 - c2 + N / 5 + 1, -c2 + c3 + (N - 1) / 5 + 1), (2 * N + 5 * c0 + 3) / 10), (M + 2 * N + 1) / 5 - 1), (2 * N + 5 * c3 + 2) / 10), c2 + (N + 2) / 5), c1 + 1), c0); c4 += 1) + S1(c0, c1, c2, c3, c4, c2); diff --git a/test_inputs/codegen/cloog/pouchet.c b/test_inputs/codegen/cloog/pouchet.c index 42c03a01..c602e1fa 100644 --- a/test_inputs/codegen/cloog/pouchet.c +++ b/test_inputs/codegen/cloog/pouchet.c @@ -1,5 +1,5 @@ for (int c0 = 1; c0 <= floord(Ny, 2) + 2; c0 += 1) - for (int c1 = max(c0 - (c0 + 1) / 2 + 1, c0 - 1); c1 <= min((Ny + 2 * c0) / 4, c0); c1 += 1) + for (int c1 = max(c0 / 2 + 1, c0 - 1); c1 <= min((Ny + 2 * c0) / 4, c0); c1 += 1) if (Ny + 2 * c0 >= 4 * c1 + 1) { for (int c2 = 1; c2 <= 2; c2 += 1) { S1(c0 - c1, c1, 2 * c0 - 2 * c1, -2 * c0 + 4 * c1, c2); diff --git a/test_inputs/codegen/cloog/reservoir-bastoul3.c b/test_inputs/codegen/cloog/reservoir-bastoul3.c index 05e95d2c..b59b93d3 100644 --- a/test_inputs/codegen/cloog/reservoir-bastoul3.c +++ b/test_inputs/codegen/cloog/reservoir-bastoul3.c @@ -1,3 +1,3 @@ for (int c0 = 3; c0 <= 9; c0 += 1) - for (int c1 = max(((c0 + 1) % 2) + 1, c0 - 6); c1 <= min(c0 - 2, 3); c1 += 2) + for (int c1 = max(-(c0 % 2) + 2, c0 - 6); c1 <= min(c0 - 2, 3); c1 += 2) S1(c0, c1, (c0 - c1) / 2); diff --git a/test_inputs/codegen/cloog/reservoir-cholesky2.c b/test_inputs/codegen/cloog/reservoir-cholesky2.c index 5d90323e..1e60bb62 100644 --- a/test_inputs/codegen/cloog/reservoir-cholesky2.c +++ b/test_inputs/codegen/cloog/reservoir-cholesky2.c @@ -2,9 +2,9 @@ for (int c1 = 2; c1 < 3 * M; c1 += 1) { if ((c1 - 2) % 3 == 0) S1((c1 + 1) / 3); for (int c3 = (c1 + 1) / 3 + 1; c3 <= min(c1 - 2, M); c3 += 1) - for (int c5 = c1 - (c1 + c3) / 2 + 1; c5 <= min(c1 - c3, c3); c5 += 1) + for (int c5 = -c3 + (c1 + c3 + 1) / 2 + 1; c5 <= min(c1 - c3, c3); c5 += 1) S3(c1 - c3 - c5 + 1, c3, c5); - if (c1 + 1 >= 3 * ((c1 - (c1 + 3) / 3 + 1) / 2) && 3 * ((c1 - (c1 + 3) / 3 + 1) / 2) + 1 >= c1) - for (int c3 = ((c1 - (c1 + 3) / 3 + 1) % 2) + (c1 + 3) / 3 + 1; c3 <= min(c1, M); c3 += 2) + if (2 * c1 + 1 >= 3 * ((c1 + c1 / 3 + 1) / 2) && 3 * ((c1 + c1 / 3 + 1) / 2) + 1 >= 2 * c1) + for (int c3 = -((c1 + c1 / 3 + 1) % 2) + c1 / 3 + 3; c3 <= min(c1, M); c3 += 2) S2((c1 - c3 + 2) / 2, c3); } diff --git a/test_inputs/codegen/cloog/reservoir-lim-lam3.c b/test_inputs/codegen/cloog/reservoir-lim-lam3.c dissimilarity index 67% index bd64f099..d011975f 100644 --- a/test_inputs/codegen/cloog/reservoir-lim-lam3.c +++ b/test_inputs/codegen/cloog/reservoir-lim-lam3.c @@ -1,11 +1,11 @@ -for (int c1 = 5; c1 <= 5 * M; c1 += 1) { - for (int c3 = max(2, -floord(M - c1 - 1, 4) - 1); c3 < min((c1 + 1) / 3 - 2, M); c3 += 1) - for (int c5 = max(c1 - c3 - (M + c1 + 1) / 2 - 2, 1); c5 < min(c3, -2 * c3 + (c1 + c3) / 2 - 2); c5 += 1) - S1(c1 - 2 * c3 - 2 * c5 - 5, c3, c5); - for (int c3 = max(1, -floord(M - c1 - 1, 4) - 1); c3 < (c1 + 1) / 5; c3 += 1) - S2(c1 - 4 * c3 - 3, c3); - if (c1 % 5 == 0) - S4(c1 / 5); - for (int c3 = max(-((c1 + 2) % 3) + 3, 2 * c1 - 3 * ((M + c1 + 1) / 2) + 1); c3 < (c1 + 1) / 5; c3 += 3) - S3((c1 - 2 * c3 - 1) / 3, c3); -} +for (int c1 = 5; c1 <= 5 * M; c1 += 1) { + for (int c3 = max(2, floord(-M + c1, 4)); c3 < min((c1 + 1) / 3 - 2, M); c3 += 1) + for (int c5 = max(-M - c3 + (M + c1) / 2 - 2, 1); c5 < min(c3, -2 * c3 + (c1 + c3) / 2 - 2); c5 += 1) + S1(c1 - 2 * c3 - 2 * c5 - 5, c3, c5); + for (int c3 = max(1, floord(-M + c1, 4)); c3 < (c1 + 1) / 5; c3 += 1) + S2(c1 - 4 * c3 - 3, c3); + if (c1 % 5 == 0) + S4(c1 / 5); + for (int c3 = max(-((c1 - 1) % 3) + 3, -3 * M - c1 + 3 * ((M + c1) / 2) + 1); c3 < (c1 + 1) / 5; c3 += 3) + S3((c1 - 2 * c3 - 1) / 3, c3); +} diff --git a/test_inputs/codegen/cloog/reservoir-liu-zhuge1.c b/test_inputs/codegen/cloog/reservoir-liu-zhuge1.c index 78712cab..987c2801 100644 --- a/test_inputs/codegen/cloog/reservoir-liu-zhuge1.c +++ b/test_inputs/codegen/cloog/reservoir-liu-zhuge1.c @@ -4,7 +4,7 @@ if (N >= 0 && M >= 0) S2(M, -3 * M + c1); } else if (3 * floord(c1 - 2, 3) + 2 == c1 && c1 + 1 >= 0 && 3 * M >= c1 + 4) S1((c1 + 4) / 3, 0); - for (int c3 = max(c1 - 3 * floord(c1, 3), -3 * M + c1 + 3); c3 <= min(c1, N - 1); c3 += 3) { + for (int c3 = max(c1 + 3 * floord(-c1 - 1, 3) + 3, -3 * M + c1 + 3); c3 <= min(c1, N - 1); c3 += 3) { S2((c1 - c3) / 3, c3); S1((c1 - c3 + 3) / 3, c3 + 1); } @@ -12,6 +12,6 @@ if (N >= 0 && M >= 0) S2((-N + c1) / 3, N); } else if (N >= c1 + 4) S1(0, c1 + 4); - for (int c3 = max(-3 * M + c1, c1 - 3 * floord(c1, 3)); c3 <= min(N, c1); c3 += 3) + for (int c3 = max(-3 * M + c1, c1 + 3 * floord(-c1 - 1, 3) + 3); c3 <= min(N, c1); c3 += 3) S3((c1 - c3) / 3, c3); } diff --git a/test_inputs/codegen/cloog/reservoir-pingali5.c b/test_inputs/codegen/cloog/reservoir-pingali5.c index fe2d283c..51f2f0c1 100644 --- a/test_inputs/codegen/cloog/reservoir-pingali5.c +++ b/test_inputs/codegen/cloog/reservoir-pingali5.c @@ -1,10 +1,10 @@ for (int c1 = 3; c1 < 2 * M; c1 += 1) { - for (int c3 = c1 - (c1 + 1) / 2 + 2; c3 <= M; c3 += 1) - for (int c7 = c1 - (c1 + 1) / 2 + 1; c7 < min(c1, c3); c7 += 1) + for (int c3 = c1 / 2 + 2; c3 <= M; c3 += 1) + for (int c7 = c1 / 2 + 1; c7 < min(c1, c3); c7 += 1) S1(c7, c1 - c7, c3); for (int c3 = max(1, -M + c1); c3 < (c1 + 1) / 2; c3 += 1) S2(c1 - c3, c3); - for (int c3 = c1 - (c1 + 1) / 2 + 2; c3 <= M; c3 += 1) - for (int c7 = c1 - (c1 + 1) / 2 + 1; c7 < min(c1, c3); c7 += 1) + for (int c3 = c1 / 2 + 2; c3 <= M; c3 += 1) + for (int c7 = c1 / 2 + 1; c7 < min(c1, c3); c7 += 1) S3(c7, c1 - c7, c3); } diff --git a/test_inputs/codegen/cloog/vivien.c b/test_inputs/codegen/cloog/vivien.c index 70e2fb77..29470ed2 100644 --- a/test_inputs/codegen/cloog/vivien.c +++ b/test_inputs/codegen/cloog/vivien.c @@ -12,7 +12,7 @@ for (int c2 = 1; c2 < (c0 + 1) / 2 - 1; c2 += 1) S5(c0 - c0 / 2 - 1, c0 / 2 + 1, c2); } - for (int c1 = -((c0 + 1) / 2) + 3; c1 <= min(n - c0, -1); c1 += 1) { + for (int c1 = -c0 + c0 / 2 + 3; c1 <= min(n - c0, -1); c1 += 1) { S6(-c1 + 2, c0 + c1 - 2); S4(-c1, c0 + c1); for (int c2 = 1; c2 <= -c1; c2 += 1) @@ -61,7 +61,7 @@ for (int c2 = 1; c2 < (c0 + 1) / 2 - 1; c2 += 1) S5(c0 - c0 / 2 - 1, c0 / 2 + 1, c2); } - for (int c1 = -((c0 + 1) / 2) + 3; c1 <= n - c0; c1 += 1) { + for (int c1 = -c0 + c0 / 2 + 3; c1 <= n - c0; c1 += 1) { S6(-c1 + 2, c0 + c1 - 2); S4(-c1, c0 + c1); for (int c2 = 1; c2 <= -c1; c2 += 1) diff --git a/test_inputs/codegen/cloog/vivien2.c b/test_inputs/codegen/cloog/vivien2.c index 4cb18640..3a679b62 100644 --- a/test_inputs/codegen/cloog/vivien2.c +++ b/test_inputs/codegen/cloog/vivien2.c @@ -13,7 +13,7 @@ S5(c0 - c0 / 2 - 1, c0 / 2 + 1, c2); } } - for (int c1 = -((c0 + 1) / 2) + 3; c1 <= min(n - c0, -1); c1 += 1) { + for (int c1 = -c0 + c0 / 2 + 3; c1 <= min(n - c0, -1); c1 += 1) { S6(-c1 + 2, c0 + c1 - 2); S4(-c1, c0 + c1); for (int c2 = 1; c2 <= -c1; c2 += 1) @@ -57,7 +57,7 @@ for (int c2 = 1; c2 < (c0 + 1) / 2 - 1; c2 += 1) S5(c0 - c0 / 2 - 1, c0 / 2 + 1, c2); } - for (int c1 = -((c0 + 1) / 2) + 3; c1 <= n - c0; c1 += 1) { + for (int c1 = -c0 + c0 / 2 + 3; c1 <= n - c0; c1 += 1) { S6(-c1 + 2, c0 + c1 - 2); S4(-c1, c0 + c1); for (int c2 = 1; c2 <= -c1; c2 += 1) diff --git a/test_inputs/codegen/omega/floor_bound-0.c b/test_inputs/codegen/omega/floor_bound-0.c index 534b50ea..959f2684 100644 --- a/test_inputs/codegen/omega/floor_bound-0.c +++ b/test_inputs/codegen/omega/floor_bound-0.c @@ -1,2 +1,2 @@ -for (int c0 = -4 * floord(floord(-m, 3), 4); c0 <= floord(n, 3); c0 += 4) +for (int c0 = 4 * floord(floord(m - 1, 3), 4) + 4; c0 <= floord(n, 3); c0 += 4) s0(c0); diff --git a/test_inputs/codegen/omega/floor_bound-1.c b/test_inputs/codegen/omega/floor_bound-1.c index b1420ce0..bc879829 100644 --- a/test_inputs/codegen/omega/floor_bound-1.c +++ b/test_inputs/codegen/omega/floor_bound-1.c @@ -1,2 +1,2 @@ -for (int c0 = -floord(-m - 1, 4) - 1; c0 <= n; c0 += 1) +for (int c0 = floord(m, 4); c0 <= n; c0 += 1) s0(c0); diff --git a/test_inputs/codegen/omega/hpf-0.c b/test_inputs/codegen/omega/hpf-0.c index 8b52b22d..c8fecaa8 100644 --- a/test_inputs/codegen/omega/hpf-0.c +++ b/test_inputs/codegen/omega/hpf-0.c @@ -1,4 +1,4 @@ if (P1 == P2 && P2 <= 3 && P2 >= 0) for (int c0 = 0; c0 <= min(2, -P2 + 4); c0 += 1) - for (int c2 = -((P2 + c0 + 2) % 3) + 2; c2 <= 3; c2 += 3) + for (int c2 = -P2 - c0 + 3 * floord(P2 + c0 - 1, 3) + 3; c2 <= 3; c2 += 3) s0(c0, c0, c2, c2); diff --git a/test_inputs/codegen/omega/iter8-0.c b/test_inputs/codegen/omega/iter8-0.c index 280b7066..505dd79a 100644 --- a/test_inputs/codegen/omega/iter8-0.c +++ b/test_inputs/codegen/omega/iter8-0.c @@ -1,2 +1,2 @@ -for (int c0 = max(exprVar2 - 8 * floord(exprVar2 - exprVar1, 8) + 1, exprVar2 + 1); c0 <= 16; c0 += 8) +for (int c0 = max(exprVar2 + 8 * floord(-exprVar2 + exprVar1 - 1, 8) + 9, exprVar2 + 1); c0 <= 16; c0 += 8) s0(c0); diff --git a/test_inputs/codegen/omega/lefur00-0.c b/test_inputs/codegen/omega/lefur00-0.c dissimilarity index 76% index b3873c08..1cd7fc35 100644 --- a/test_inputs/codegen/omega/lefur00-0.c +++ b/test_inputs/codegen/omega/lefur00-0.c @@ -1,5 +1,5 @@ -for (int c0 = 0; c0 <= 15; c0 += 1) - for (int c1 = max(c0 - (c0 + 1) / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) - for (int c2 = max(max(max(67 * c0 - (c0 + 1) / 3, 133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66), 67 * c1 - floord(c1 - 1, 3) - 1), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) - for (int c3 = max(max(200 * c0 - c2, 100 * c1 + c2 - c2 / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) - s0(c0, c1, c2, c3); +for (int c0 = 0; c0 <= 15; c0 += 1) + for (int c1 = max(c0 / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) + for (int c2 = max(max(max(67 * c0 - (c0 + 1) / 3, 133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66), 67 * c1 - (c1 + 2) / 3), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) + for (int c3 = max(max(200 * c0 - c2, 100 * c1 + (c2 + 1) / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) + s0(c0, c1, c2, c3); diff --git a/test_inputs/codegen/omega/lefur01-0.c b/test_inputs/codegen/omega/lefur01-0.c dissimilarity index 76% index b3873c08..1cd7fc35 100644 --- a/test_inputs/codegen/omega/lefur01-0.c +++ b/test_inputs/codegen/omega/lefur01-0.c @@ -1,5 +1,5 @@ -for (int c0 = 0; c0 <= 15; c0 += 1) - for (int c1 = max(c0 - (c0 + 1) / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) - for (int c2 = max(max(max(67 * c0 - (c0 + 1) / 3, 133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66), 67 * c1 - floord(c1 - 1, 3) - 1), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) - for (int c3 = max(max(200 * c0 - c2, 100 * c1 + c2 - c2 / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) - s0(c0, c1, c2, c3); +for (int c0 = 0; c0 <= 15; c0 += 1) + for (int c1 = max(c0 / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) + for (int c2 = max(max(max(67 * c0 - (c0 + 1) / 3, 133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66), 67 * c1 - (c1 + 2) / 3), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) + for (int c3 = max(max(200 * c0 - c2, 100 * c1 + (c2 + 1) / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) + s0(c0, c1, c2, c3); diff --git a/test_inputs/codegen/omega/lefur01-1.c b/test_inputs/codegen/omega/lefur01-1.c dissimilarity index 76% index 804a9ef7..c10688a4 100644 --- a/test_inputs/codegen/omega/lefur01-1.c +++ b/test_inputs/codegen/omega/lefur01-1.c @@ -1,5 +1,5 @@ -for (int c0 = 0; c0 <= 15; c0 += 1) - for (int c1 = max(c0 - (c0 + 1) / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) - for (int c2 = max(max(max(133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66, 67 * c1 - floord(c1 - 1, 3) - 1), 67 * c0 - (c0 + 1) / 3), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) - for (int c3 = max(max(200 * c0 - c2, 100 * c1 + c2 - c2 / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) - s0(c0, c1, c2, c3); +for (int c0 = 0; c0 <= 15; c0 += 1) + for (int c1 = max(c0 / 2, 2 * c0 - 15); c1 <= min(c0 + 1, 15); c1 += 1) + for (int c2 = max(max(max(133 * c0 - 67 * c1 + (c0 + c1 + 1) / 3 - 66, 67 * c1 - (c1 + 2) / 3), 67 * c0 - (c0 + 1) / 3), 1); c2 <= min(min(133 * c0 - 67 * c1 + floord(c0 + c1 - 1, 3) + 133, 100 * c0 + 99), 1000); c2 += 1) + for (int c3 = max(max(200 * c0 - c2, 100 * c1 + (c2 + 1) / 2), c2); c3 <= min(min(100 * c1 + (c2 + 1) / 2 + 99, 2 * c2 + 1), 200 * c0 - c2 + 199); c3 += 1) + s0(c0, c1, c2, c3); diff --git a/test_inputs/codegen/omega/lefur03-0.c b/test_inputs/codegen/omega/lefur03-0.c dissimilarity index 62% index 3e58184b..2b6d7b28 100644 --- a/test_inputs/codegen/omega/lefur03-0.c +++ b/test_inputs/codegen/omega/lefur03-0.c @@ -1,7 +1,7 @@ -for (int c0 = 0; c0 <= 3; c0 += 1) - for (int c1 = max(0, 2 * c0 - 3); c1 <= min(c0 + c0 / 2 + 1, 3); c1 += 1) - for (int c2 = c0; c2 <= min(min(3, 3 * c1 + 2), 2 * c0 - c1 + 1); c2 += 1) - for (int c3 = max(max(max(c1 + (c1 + 2) / 3 - 1, 0), c1 + c2 - (3 * c1 + c2) / 6 - 1), 2 * c0 - (c0 + c1 + 1) / 3 - 1); c3 <= min(c0 + 1, 3); c3 += 1) - for (int c4 = max(max(max(max(-200 * c1 + 400 * c3 - 199, 333 * c1 + (c1 + 3) / 3 - 1), 333 * c2 + (c2 + 1) / 3), 667 * c0 - 333 * c1 - (c0 + c1) / 3 - 333), 250 * c3 + 1); c4 <= min(min(min(min(500 * c0 + 499, -200 * c1 + 400 * c3 + 400), 333 * c3 - (-c3 + 3) / 3 + 334), 1000), 333 * c2 - (-c2 + 3) / 3 + 333); c4 += 1) - for (int c5 = max(max(max(1000 * c3 - 2 * c4 + 2, 1000 * c0 - c4), 500 * c1 + c4 - c4 / 2), c4); c5 <= min(min(min(1000 * c3 - 2 * c4 + 1001, 1000 * c0 - c4 + 999), 500 * c1 + (c4 + 1) / 2 + 499), 2 * c4 + 1); c5 += 1) - s0(c0, c1, c2, c3, c4, c5); +for (int c0 = 0; c0 <= 3; c0 += 1) + for (int c1 = max(0, 2 * c0 - 3); c1 <= min(c0 + c0 / 2 + 1, 3); c1 += 1) + for (int c2 = c0; c2 <= min(min(3, 3 * c1 + 2), 2 * c0 - c1 + 1); c2 += 1) + for (int c3 = max(max(max(c1 - (-c1 + 3) / 3, 0), c2 + floord(3 * c1 - c2 - 1, 6)), 2 * c0 - (c0 + c1 + 1) / 3 - 1); c3 <= min(c0 + 1, 3); c3 += 1) + for (int c4 = max(max(max(max(-200 * c1 + 400 * c3 - 199, 333 * c1 + c1 / 3), 333 * c2 + (c2 + 1) / 3), 667 * c0 - 333 * c1 - (c0 + c1 + 3) / 3 - 332), 250 * c3 + 1); c4 <= min(min(min(min(500 * c0 + 499, -200 * c1 + 400 * c3 + 400), 333 * c3 - (-c3 + 3) / 3 + 334), 1000), 333 * c2 - (-c2 + 3) / 3 + 333); c4 += 1) + for (int c5 = max(max(max(1000 * c3 - 2 * c4 + 2, 1000 * c0 - c4), 500 * c1 + (c4 + 1) / 2), c4); c5 <= min(min(min(1000 * c3 - 2 * c4 + 1001, 1000 * c0 - c4 + 999), 500 * c1 + (c4 + 1) / 2 + 499), 2 * c4 + 1); c5 += 1) + s0(c0, c1, c2, c3, c4, c5); diff --git a/test_inputs/codegen/omega/lefur04-0.c b/test_inputs/codegen/omega/lefur04-0.c dissimilarity index 76% index b531bf60..079505ef 100644 --- a/test_inputs/codegen/omega/lefur04-0.c +++ b/test_inputs/codegen/omega/lefur04-0.c @@ -1,8 +1,8 @@ -for (int c0 = 0; c0 <= 3; c0 += 1) - for (int c1 = max(0, 2 * c0 - 3); c1 <= min(c0 + 1, 3); c1 += 1) - for (int c2 = c0; c2 <= min(min(3, 3 * c1 + 2), 2 * c0 - c1 + 1); c2 += 1) - for (int c3 = max(max(max(c2 + (-c2 + 3) / 3 - 1, c1 + c2 - (3 * c1 + c2) / 6 - 1), c1 + (c1 + 2) / 3 - 1), c0 + (c2 + 2) / 3 - 1); c3 <= min(c0 + c0 / 2 + 1, 3); c3 += 1) - for (int c5 = max(max(max(max(c1 + (c1 + 2) / 3 - 1, 0), 2 * c3 - 4), c3 - c3 / 3 - 1), c2 - c2 / 3 - 1); c5 <= min(min(-c2 + 2 * c3 - (c2 + 3) / 3 + 2, c1 + 1), c3); c5 += 1) - for (int c6 = max(max(max(max(max(250 * c3 + 1, 667 * c0 - 333 * c1 - (c0 + c1) / 3 - 333), -200 * c1 + 400 * c3 - 199), 333 * c1 + (c1 + 3) / 3 - 1), 1000 * c0 - 500 * c5 - 501), 333 * c2 + (c2 + 1) / 3); c6 <= min(min(min(min(min(min(333 * c3 - (-c3 + 3) / 3 + 334, 1000), 333 * c2 - (-c2 + 3) / 3 + 333), 1000 * c0 - 500 * c5 + 997), 500 * c5 + 501), 500 * c0 + 499), -200 * c1 + 400 * c3 + 400); c6 += 1) - for (int c7 = max(max(max(max(c6, 500 * c1 + c6 - c6 / 2), 1000 * c0 - c6), 500 * c5 + 2), 1000 * c3 - 2 * c6 + 2); c7 <= min(min(min(min(500 * c5 + 501, 2 * c6 + 1), 1000 * c3 - 2 * c6 + 1001), 1000 * c0 - c6 + 999), 500 * c1 + (c6 + 1) / 2 + 499); c7 += 1) - s0(c0, c1, c2, c3, c2 / 3, c5, c6, c7); +for (int c0 = 0; c0 <= 3; c0 += 1) + for (int c1 = max(0, 2 * c0 - 3); c1 <= min(c0 + 1, 3); c1 += 1) + for (int c2 = c0; c2 <= min(min(3, 3 * c1 + 2), 2 * c0 - c1 + 1); c2 += 1) + for (int c3 = max(max(max(c2 - (c2 + 2) / 3, c2 + floord(3 * c1 - c2 - 1, 6)), c1 - (-c1 + 3) / 3), c0 - (-c2 + 3) / 3); c3 <= min(c0 + c0 / 2 + 1, 3); c3 += 1) + for (int c5 = max(max(max(max(c1 - (-c1 + 3) / 3, 0), 2 * c3 - 4), c3 - (c3 + 3) / 3), c2 - (c2 + 3) / 3); c5 <= min(min(-c2 + 2 * c3 - (c2 + 3) / 3 + 2, c1 + 1), c3); c5 += 1) + for (int c6 = max(max(max(max(max(250 * c3 + 1, 667 * c0 - 333 * c1 - (c0 + c1 + 3) / 3 - 332), -200 * c1 + 400 * c3 - 199), 333 * c1 + c1 / 3), 1000 * c0 - 500 * c5 - 501), 333 * c2 + (c2 + 1) / 3); c6 <= min(min(min(min(min(min(333 * c3 - (-c3 + 3) / 3 + 334, 1000), 333 * c2 - (-c2 + 3) / 3 + 333), 1000 * c0 - 500 * c5 + 997), 500 * c5 + 501), 500 * c0 + 499), -200 * c1 + 400 * c3 + 400); c6 += 1) + for (int c7 = max(max(max(max(c6, 500 * c1 + (c6 + 1) / 2), 1000 * c0 - c6), 500 * c5 + 2), 1000 * c3 - 2 * c6 + 2); c7 <= min(min(min(min(500 * c5 + 501, 2 * c6 + 1), 1000 * c3 - 2 * c6 + 1001), 1000 * c0 - c6 + 999), 500 * c1 + (c6 + 1) / 2 + 499); c7 += 1) + s0(c0, c1, c2, c3, c2 / 3, c5, c6, c7); diff --git a/test_inputs/codegen/omega/m11-0.c b/test_inputs/codegen/omega/m11-0.c index e0abe481..e1c320c0 100644 --- a/test_inputs/codegen/omega/m11-0.c +++ b/test_inputs/codegen/omega/m11-0.c @@ -1,6 +1,6 @@ for (int c0 = 1; c0 <= min(4, floord(2 * m - 1, 17) + 1); c0 += 1) for (int c1 = 1; c1 <= 2; c1 += 1) for (int c2 = 0; c2 <= min(-c1 + c1 / 2 + 3, -c0 - c1 + (2 * m + 3 * c0 + 10 * c1 + 6) / 20 + 1); c2 += 1) - for (int c3 = 9 * c0 - c0 / 2 - 8; c3 <= min(min(m - 5 * c1 - 10 * c2 + 5, 8 * c0 + c0 / 2), 30); c3 += 1) + for (int c3 = 8 * c0 + (c0 + 1) / 2 - 8; c3 <= min(min(m - 5 * c1 - 10 * c2 + 5, 8 * c0 + c0 / 2), 30); c3 += 1) for (int c4 = 5 * c1 + 10 * c2 - 4; c4 <= min(m - c3 + 1, 5 * c1 + 10 * c2); c4 += 1) s0(c0, c1, c2, c3, c4, -9 * c0 + c3 + c0 / 2 + 9, -5 * c1 - 5 * c2 + c4 + 5); diff --git a/test_inputs/codegen/omega/p.delft-0.c b/test_inputs/codegen/omega/p.delft-0.c index 8b52b22d..c8fecaa8 100644 --- a/test_inputs/codegen/omega/p.delft-0.c +++ b/test_inputs/codegen/omega/p.delft-0.c @@ -1,4 +1,4 @@ if (P1 == P2 && P2 <= 3 && P2 >= 0) for (int c0 = 0; c0 <= min(2, -P2 + 4); c0 += 1) - for (int c2 = -((P2 + c0 + 2) % 3) + 2; c2 <= 3; c2 += 3) + for (int c2 = -P2 - c0 + 3 * floord(P2 + c0 - 1, 3) + 3; c2 <= 3; c2 += 3) s0(c0, c0, c2, c2); diff --git a/test_inputs/codegen/omega/stride6-0.c b/test_inputs/codegen/omega/stride6-0.c index d6bd4d41..5f619bf5 100644 --- a/test_inputs/codegen/omega/stride6-0.c +++ b/test_inputs/codegen/omega/stride6-0.c @@ -1,3 +1,3 @@ for (int c0 = 1; c0 <= 101; c0 += 1) - for (int c1 = (c0 % 2) + c0; c1 <= 400; c1 += 2) + for (int c1 = -((c0 + 1) % 2) + c0 + 1; c1 <= 400; c1 += 2) s0(c0, c1); diff --git a/test_inputs/codegen/omega/substitution-1.c b/test_inputs/codegen/omega/substitution-1.c index b394e5c7..51ab952e 100644 --- a/test_inputs/codegen/omega/substitution-1.c +++ b/test_inputs/codegen/omega/substitution-1.c @@ -1,3 +1,3 @@ for (int c0 = 0; c0 <= 14; c0 += 1) - for (int c1 = max(2 * c0 - 12, 2 * c0 - 3 * (c0 / 2)); c1 <= min(2 * c0, c0 / 2 + 9); c1 += 3) + for (int c1 = max(2 * c0 - 12, -c0 + 3 * ((c0 + 1) / 2)); c1 <= min(2 * c0, c0 / 2 + 9); c1 += 3) s0((2 * c0 - c1) / 3, (-c0 + 2 * c1) / 3); diff --git a/test_inputs/codegen/omega/ts1d-check0-0.c b/test_inputs/codegen/omega/ts1d-check0-0.c index e00eb91b..d252bdf9 100644 --- a/test_inputs/codegen/omega/ts1d-check0-0.c +++ b/test_inputs/codegen/omega/ts1d-check0-0.c @@ -3,7 +3,7 @@ s0(1, c1, 1, 0, 0); for (int c1 = 0; c1 <= floord(T - 1, 500); c1 += 1) for (int c2 = 1000 * c1; c2 <= min(N + 1000 * c1 + 997, N + 2 * T - 3); c2 += 1) { - for (int c3 = max(0, ((N + c2 + 1) % 2) - N - 1000 * c1 + c2 + 1); c3 <= min(min(2 * T - 1000 * c1 - 2, 998), -1000 * c1 + c2 - 2); c3 += 2) { + for (int c3 = max(0, -((N + c2) % 2) - N - 1000 * c1 + c2 + 2); c3 <= min(min(2 * T - 1000 * c1 - 2, 998), -1000 * c1 + c2 - 2); c3 += 2) { s1(2, 1000 * c1 + c3, 0, -1000 * c1 + c2 - c3, 1); s2(2, 1000 * c1 + c3 + 1, 0, -1000 * c1 + c2 - c3 - 1, 1); } diff --git a/test_inputs/codegen/omega/ts1d-mp-i_ts-m_b-0.c b/test_inputs/codegen/omega/ts1d-mp-i_ts-m_b-0.c index 1ab5459b..c8526f0d 100644 --- a/test_inputs/codegen/omega/ts1d-mp-i_ts-m_b-0.c +++ b/test_inputs/codegen/omega/ts1d-mp-i_ts-m_b-0.c @@ -8,27 +8,27 @@ } else if (c1 + 1 == 0 && c2 >= 0 && N >= c2 + 1) s0(1, -1, c2, 0, 0); for (int c1 = 0; c1 <= floord(T - 1, 500); c1 += 1) { - for (int c3 = -((c1 + 1) / 8) + 1; c3 <= floord(N - 500 * c1 - 3, 4000) + 1; c3 += 1) + for (int c3 = -((c1 + 9) / 8) + 2; c3 <= floord(N - 500 * c1 - 3, 4000) + 1; c3 += 1) for (int c4 = max(1000 * c1 + 4000 * c3 - 3999, 500 * c1 + 1); c4 <= min(min(2 * N - 4000 * c3 + 3995, N + T - 3), 1000 * c1 + 4000 * c3 - 3000); c4 += 1) for (int c5 = max(-N - 500 * c1 + c4 + 2, 0); c5 <= min(min(T - 500 * c1 - 1, -500 * c1 + c4 - 1), -500 * c1 - 2000 * c3 + (c4 + 1) / 2 + 1999); c5 += 1) s1(2, 500 * c1 + c5, 1, -500 * c1 + c4 - c5, 1); - for (int c3 = max(-((c1 + 1) / 8) + 1, -(T / 4000) + 1); c3 <= floord(N - 500 * c1 - 3, 4000) + 1; c3 += 1) + for (int c3 = max(-((c1 + 9) / 8) + 2, -((T + 4000) / 4000) + 2); c3 <= floord(N - 500 * c1 - 3, 4000) + 1; c3 += 1) for (int c4 = max(-4000 * c3 + 4000, 1000 * c1 + 4000 * c3 - 3999); c4 <= min(min(2 * N - 4000 * c3 + 3995, 1000 * c1 + 4000 * c3 - 3000), 2 * T + 4000 * c3 - 4000); c4 += 1) s2(2, -2000 * c3 + (c4 + 1) / 2 + 1999, 1, 2000 * c3 + c4 - (c4 + 1) / 2 - 1999, 1); - for (int c3 = -floord(c1 - 1, 8); c3 <= min(floord(N - 500 * c1 - 504, 4000) + 1, floord(N + T - 1000 * c1 - 1004, 4000) + 1); c3 += 1) + for (int c3 = -((c1 + 7) / 8) + 1; c3 <= min(floord(N - 500 * c1 - 504, 4000) + 1, floord(N + T - 1000 * c1 - 1004, 4000) + 1); c3 += 1) for (int c4 = max(1000 * c1 + 4000 * c3 - 2999, 500 * c1 + 1); c4 <= min(min(N + T - 3, N + 500 * c1 + 497), 1000 * c1 + 4000 * c3); c4 += 1) for (int c5 = max(0, -N - 500 * c1 + c4 + 2); c5 <= min(min(T - 500 * c1 - 1, -500 * c1 + c4 - 1), 499); c5 += 1) s3(2, 500 * c1 + c5, 1, -500 * c1 + c4 - c5, 1); - for (int c3 = max(-((c1 + 1) / 8), -(T / 4000)); c3 <= floord(N - 500 * c1 - 3, 4000); c3 += 1) + for (int c3 = max(-((c1 + 9) / 8) + 1, -((T + 4000) / 4000) + 1); c3 <= floord(N - 500 * c1 - 3, 4000); c3 += 1) for (int c4 = max(-4000 * c3, 1000 * c1 + 4000 * c3 + 1); c4 <= min(min(2 * N - 4000 * c3 - 5, 1000 * c1 + 4000 * c3 + 1000), 2 * T + 4000 * c3); c4 += 1) s4(2, -2000 * c3 + (c4 + 1) / 2 - 1, 1, 2000 * c3 + c4 - (c4 + 1) / 2 + 1, 1); - for (int c3 = -(c1 / 8); c3 <= min(floord(N - 500 * c1 + 496, 4000), floord(N + T - 1000 * c1 - 4, 4000)); c3 += 1) + for (int c3 = -((c1 + 8) / 8) + 1; c3 <= min(floord(N - 500 * c1 + 496, 4000), floord(N + T - 1000 * c1 - 4, 4000)); c3 += 1) for (int c4 = max(1000 * c1 + 4000 * c3 + 1, -4000 * c3 + 2); c4 <= min(min(min(1000 * c1 + 4000 * c3 + 998, N + 500 * c1 + 497), 2 * T + 4000 * c3 - 2), N + T - 3); c4 += 1) - for (int c5 = max(-N - 500 * c1 + c4 + 2, -500 * c1 - 2000 * c3 + c4 - c4 / 2); c5 <= min(min(T - 500 * c1 - 1, -500 * c1 + c4 - 1), 499); c5 += 1) + for (int c5 = max(-N - 500 * c1 + c4 + 2, -500 * c1 - 2000 * c3 + (c4 + 1) / 2); c5 <= min(min(T - 500 * c1 - 1, -500 * c1 + c4 - 1), 499); c5 += 1) s5(2, 500 * c1 + c5, 1, -500 * c1 + c4 - c5, 1); } if (T >= 1) - for (int c3 = -floord(T - 2, 4000); c3 <= floord(N - T - 2, 4000) + 1; c3 += 1) + for (int c3 = -((T + 3998) / 4000) + 1; c3 <= floord(N - T - 2, 4000) + 1; c3 += 1) for (int c4 = max(2 * T + 4000 * c3 - 4001, T); c4 < min(2 * T + 4000 * c3 - 1, N + T - 2); c4 += 1) s6(2, T - 1, 1, -T + c4 + 1, 1); } diff --git a/test_inputs/codegen/stride5.c b/test_inputs/codegen/stride5.c index 1e69f06f..080bea07 100644 --- a/test_inputs/codegen/stride5.c +++ b/test_inputs/codegen/stride5.c @@ -1,3 +1,3 @@ if (2 * floord(n, 2) == n) - for (int c0 = (n - 4 * floord(n, 4)) / 2; c0 <= 100; c0 += 2) + for (int c0 = (n + 4 * floord(-n - 1, 4) + 4) / 2; c0 <= 100; c0 += 2) S(c0); -- 2.11.4.GIT