From: Sven Verdoolaege Date: Mon, 11 Feb 2013 17:10:27 +0000 (+0100) Subject: isl_ast_graft.c: extract_hoistable_guard: drop divs involving current depth X-Git-Tag: isl-0.12~207 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac5bc82f1683ea8cc6b37dafc2b96ad1cf736cd3;p=platform%2Fupstream%2Fisl.git isl_ast_graft.c: extract_hoistable_guard: drop divs involving current depth If the current guard involves any integer divisions that refer to the dimension corresponding to the current depth, then the expressions for these integer divisions will be invalidated after projecting out this dimension. This means that new expressions will have to be computed and this may in some cases lead to complicated results with many subcases. Such complicated guards will not be useful for the purpose of simplifying the AST and so there is little point in hoisting such guards. We therefore first drop any integer divisions that refer to the dimension corresponding to the current depth. This should typically lead to simpler hoisted guards. Signed-off-by: Sven Verdoolaege --- diff --git a/isl_ast_graft.c b/isl_ast_graft.c index 627393b..ea37ab6 100644 --- a/isl_ast_graft.c +++ b/isl_ast_graft.c @@ -178,6 +178,8 @@ static __isl_give isl_set *extract_hoistable_guard( depth = isl_ast_build_get_depth(build); if (depth < isl_set_dim(guard, isl_dim_set)) { + guard = isl_set_remove_divs_involving_dims(guard, + isl_dim_set, depth, 1); guard = isl_set_eliminate(guard, isl_dim_set, depth, 1); guard = isl_set_compute_divs(guard); } diff --git a/test_inputs/codegen/omega/p.delft2-0.c b/test_inputs/codegen/omega/p.delft2-0.c index 99d4005..2380aef 100644 --- a/test_inputs/codegen/omega/p.delft2-0.c +++ b/test_inputs/codegen/omega/p.delft2-0.c @@ -1,10 +1,10 @@ -if ((2 * floord(P2, 2) == P2 && 2 * floord(P1, 2) == P1 && P2 >= 0 && P2 <= 3 && P1 >= 0 && P1 <= 3) || (2 * floord(P2, 2) == P2 && 2 * floord(P1 - 1, 2) + 1 == P1 && P2 >= 0 && P2 <= 3 && P1 >= 0 && P1 <= 3) || (2 * floord(P2 - 1, 2) + 1 == P2 && 2 * floord(P1, 2) == P1 && P2 >= 0 && P2 <= 3 && P1 >= 0 && P1 <= 3) || (2 * floord(P2 - 1, 2) + 1 == P2 && 2 * floord(P1 - 1, 2) + 1 == P1 && P2 >= 0 && P2 <= 3 && P1 >= 0 && P1 <= 3)) +if (P2 >= 0 && P2 <= 3 && P1 >= 0 && P1 <= 3) for (int c0 = P1 - 1; c0 <= 3; c0 += 1) - if ((2 * floord(c0, 2) == c0 && P2 % 2 == 0 && 2 * floord(P1 - 1, 2) + 1 == P1) || (2 * floord(c0, 2) == c0 && 2 * floord(P2 - 1, 2) + 1 == P2 && 2 * floord(P1 - 1, 2) + 1 == P1) || (2 * floord(c0 - 1, 2) + 1 == c0 && P2 % 2 == 0 && P1 % 2 == 0) || (2 * floord(c0 - 1, 2) + 1 == c0 && 2 * floord(P2 - 1, 2) + 1 == P2 && P1 % 2 == 0)) + if (P1 + 2 * floord(-P1 + c0 - 1, 2) + 1 == c0) for (int c2 = 0; c2 <= -((P1 + 4) / 4) + 8; c2 += 1) - if ((-2 * ((-P2 + 4) / 4) + 2 * (P2 / 4) + 2 == P2 && 2 * floord(P2 - 1, 2) + 2 == P2 && P2 <= 6 && 18 * floord(9 * P1 + 17 * c0 + 14 * c2 + 3, 18) + 1 >= 9 * P1 + 17 * c0 + 14 * c2) || (2 * floord(P2 - 1, 2) + 1 == P2 && P2 + 1 >= 0 && 18 * floord(9 * P1 + 17 * c0 + 14 * c2 + 3, 18) + 1 >= 9 * P1 + 17 * c0 + 14 * c2 && (-P2 + 4) % 4 >= 1)) + if ((9 * P1 + c0 + 4 * c2 + 1) % 18 <= 4) for (int c3 = 0; c3 <= -((P2 + 4) / 4) + 8; c3 += 1) - if ((5 * P2 + 2 * c3) % 9 <= 3 && 9 * ((4 * P2 + 3) / 9 / 2) + 7 >= 2 * P2 && 2 * P2 + 1 >= 9 * ((4 * P2 + 3) / 9 / 2)) + if ((5 * P2 + 2 * c3) % 9 <= 3) if (c0 + 1 == P1 && (5 * P1 + 2 * c2) % 9 <= 2 && P1 >= 1) { s0(P1 - 1, P2, c2, c3, ((5 * P1 + 2 * c2) % 9) + 1, (-4 * P2 + 2 * c3 + 9) % 9); } else if (c2 % 4 == 0 && c0 == 3 && P1 == 0)