> Any reason you don't use isl_id_for_pbb() to create this isl_id? Yes, it is redundant. I've used isl_id_for_pbb() in the improved version.
> Otherwise, the patch looks good to me. You can commit it if the graphite > tests still pass and you add an appropriate ChangeLog entry. I haven't found out regression during testing with the graphite tests. > This patch looks also good. Can you quickly repost with the two test cases as > well as the appropriate ChangeLog, before I give the final OK. If I'm not mistaken, I sent you only one test case. Should we create another one? -- Cheers, Roman Gareev.
2014-07-26 Roman Gareev <gareevro...@gmail.com> [gcc/] * graphite-sese-to-poly.c: (new_pbb_from_pbb): Set a new id of pbb1->domain (instead of using the id of the pbb), which contains pointer to the pbb1.
2014-07-26 Roman Gareev <gareevro...@gmail.com> [gcc/] * graphite-isl-ast-to-gimple.c: (graphite_create_new_guard): New function. (translate_isl_ast_node_if): New function. (translate_isl_ast): Add calling of translate_isl_ast_node_if. [gcc/testsuite] * gcc.dg/graphite/isl-ast-gen-if-1.c: New testcase.
Index: gcc/graphite-sese-to-poly.c =================================================================== --- gcc/graphite-sese-to-poly.c (revision 212995) +++ gcc/graphite-sese-to-poly.c (working copy) @@ -2044,7 +2044,8 @@ break; pbb1->domain = isl_set_copy (pbb->domain); - + pbb1->domain = isl_set_set_tuple_id (pbb1->domain, + isl_id_for_pbb (scop, pbb1)); GBB_PBB (gbb1) = pbb1; GBB_CONDITIONS (gbb1) = GBB_CONDITIONS (gbb).copy (); GBB_CONDITION_CASES (gbb1) = GBB_CONDITION_CASES (gbb).copy ();
Index: gcc/graphite-isl-ast-to-gimple.c =================================================================== --- gcc/graphite-isl-ast-to-gimple.c (revision 212995) +++ gcc/graphite-isl-ast-to-gimple.c (working copy) @@ -646,6 +646,43 @@ return next_e; } +/* Creates a new if region corresponding to ISL's cond. */ + +static edge +graphite_create_new_guard (edge entry_edge, __isl_take isl_ast_expr *if_cond, + ivs_params &ip) +{ + tree type = + build_nonstandard_integer_type (graphite_expression_type_precision, 0); + tree cond_expr = gcc_expression_from_isl_expression (type, if_cond, ip); + edge exit_edge = create_empty_if_region_on_edge (entry_edge, cond_expr); + return exit_edge; +} + +/* Translates an isl_ast_node_if to Gimple. */ + +static edge +translate_isl_ast_node_if (loop_p context_loop, + __isl_keep isl_ast_node *node, + edge next_e, ivs_params &ip) +{ + gcc_assert (isl_ast_node_get_type (node) == isl_ast_node_if); + isl_ast_expr *if_cond = isl_ast_node_if_get_cond (node); + edge last_e = graphite_create_new_guard (next_e, if_cond, ip); + + edge true_e = get_true_edge_from_guard_bb (next_e->dest); + isl_ast_node *then_node = isl_ast_node_if_get_then (node); + translate_isl_ast (context_loop, then_node, true_e, ip); + isl_ast_node_free (then_node); + + edge false_e = get_false_edge_from_guard_bb (next_e->dest); + isl_ast_node *else_node = isl_ast_node_if_get_else (node); + if (isl_ast_node_get_type (else_node) != isl_ast_node_error) + translate_isl_ast (context_loop, else_node, false_e, ip); + isl_ast_node_free (else_node); + return last_e; +} + /* Translates an ISL AST node NODE to GCC representation in the context of a SESE. */ @@ -663,7 +700,8 @@ next_e, ip); case isl_ast_node_if: - return next_e; + return translate_isl_ast_node_if (context_loop, node, + next_e, ip); case isl_ast_node_user: return translate_isl_ast_node_user (node, next_e, ip); Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c =================================================================== --- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c (revision 0) +++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-if-1.c (working copy) @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fgraphite-identity -fgraphite-code-generator=isl" } */ + +static int __attribute__((noinline)) +foo () +{ + int i, res = 0; + + for (i = 0; i < 50; i++) + { + if (i >= 25) + res += i; + } + + return res; +} + +extern void abort (); + +int +main (void) +{ + int res = foo (); + + if (res != 925) + abort (); + + return 0; +}