public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [GSoC] generation of Gimple code from isl_ast_node_if
@ 2014-07-24 10:10 Roman Gareev
  2014-07-24 10:46 ` Tobias Grosser
  2014-07-26  9:35 ` Tobias Grosser
  0 siblings, 2 replies; 19+ messages in thread
From: Roman Gareev @ 2014-07-24 10:10 UTC (permalink / raw)
  To: Tobias Grosser; +Cc: Mircea Namolaru, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

I've attached the patch, which contains generation of Gimple code from
isl_ast_node_if.

However, I've found out a problem. When I'm trying to generate Gimple
code from, for example, the following ISL AST:

{
  for (int c1 = 0; c1 <= 49; c1 += 1) {
    S_6(c1);
    if (c1 <= 48) {
      S_3(c1);
      if (c1 >= 24)
        S_4(c1);
      S_5(c1);
    }
  }
  S_7();
}

the pointer to Gimple basic block of S_3's poly basic block is NULL.

Could you please advise me possible reasons of this issue?

The source code of the example:

int
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 != 1225)
    abort ();

  return 0;
}

--
                                   Cheers, Roman Gareev.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1913 bytes --]

Index: gcc/graphite-isl-ast-to-gimple.c
===================================================================
--- gcc/graphite-isl-ast-to-gimple.c	(revision 212922)
+++ gcc/graphite-isl-ast-to-gimple.c	(working copy)
@@ -636,6 +636,42 @@
   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);
+  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.  */
 
@@ -653,7 +689,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);

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-07-27 10:53 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 10:10 [GSoC] generation of Gimple code from isl_ast_node_if Roman Gareev
2014-07-24 10:46 ` Tobias Grosser
2014-07-25 11:30   ` Roman Gareev
2014-07-25 11:44     ` Tobias Grosser
2014-07-26  9:07       ` Roman Gareev
2014-07-26  9:26         ` Tobias Grosser
2014-07-26  9:35 ` Tobias Grosser
2014-07-26 10:24   ` Roman Gareev
2014-07-26 12:59     ` Tobias Grosser
2014-07-26 13:03       ` Roman Gareev
2014-07-26 13:48         ` Tobias Grosser
2014-07-26 13:59           ` Roman Gareev
2014-07-26 14:16             ` Tobias Grosser
2014-07-26 14:28               ` Roman Gareev
2014-07-26 15:05                 ` Tobias Grosser
2014-07-27  7:33                   ` Roman Gareev
2014-07-27  7:34                     ` Tobias Grosser
2014-07-27 10:53                       ` Roman Gareev
2014-07-27 11:02                         ` Tobias Grosser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).