public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Sebastian Pop" <sebpop@gmail.com>
To: gcc-bugzilla@gcc.gnu.org
Cc: gcc-bugs@gcc.gnu.org
Subject: Re: [Bug middle-end/38431] [graphite] several ICEs with CP2K (summary)
Date: Wed, 14 Jan 2009 10:20:00 -0000	[thread overview]
Message-ID: <cb9d34b20901140220n456d6a63x54904b00a39102c6@mail.gmail.com> (raw)
In-Reply-To: <20090114064945.29249.qmail@sourceware.org>

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

Attached a fix for this PR.  I will regstrap and submit for review.

Sebastian

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 1332_pr38431.diff --]
[-- Type: text/x-patch; name=1332_pr38431.diff, Size: 3482 bytes --]

2009-01-14  Sebastian Pop  <sebastian.pop@amd.com>

	PR middle-end/38431
	* graphite.c (get_vdef_before_scop, scop_adjust_vphi): New.
	(scop_adjust_phis_for_liveouts): Call scop_adjust_vphi.
	(gloog): Do not call cleanup_tree_cfg.
	(graphite_transform_loops): Call cleanup_tree_cfg after all 
	scops have been code generated.

Index: graphite.c
===================================================================
--- graphite.c	(revision 143346)
+++ graphite.c	(working copy)
@@ -5188,6 +5188,82 @@ scop_insert_phis_for_liveouts (sese regi
   update_ssa (TODO_update_ssa);
 }
 
+/* Get the definition of NAME before the SCOP.  Keep track of the
+   basic blocks that have been VISITED in a bitmap.  */
+
+static tree
+get_vdef_before_scop (scop_p scop, tree name, sbitmap visited)
+{
+  unsigned i;
+  gimple def_stmt = SSA_NAME_DEF_STMT (name);
+  basic_block def_bb = gimple_bb (def_stmt);
+
+  if (!bb_in_scop_p (def_bb, scop))
+    return name;
+
+  if (TEST_BIT (visited, def_bb->index))
+    return NULL_TREE;
+
+  SET_BIT (visited, def_bb->index);
+
+  switch (gimple_code (def_stmt))
+    {
+    case GIMPLE_PHI:
+      for (i = 0; i < gimple_phi_num_args (def_stmt); i++)
+	{
+	  tree arg = gimple_phi_arg_def (def_stmt, i);
+	  tree res = get_vdef_before_scop (scop, arg, visited);
+	  if (res)
+	    return res;
+	}
+      return NULL_TREE;
+
+    default:
+      return NULL_TREE;
+    }
+}
+
+/* Adjust a virtual phi node PHI that is placed at the end of the
+   generated code for SCOP:
+
+   | if (1)
+   |   generated code from REGION;
+   | else
+   |   REGION;
+
+   The FALSE_E edge comes from the original code, TRUE_E edge comes
+   from the code generated for the SCOP.  */
+
+static void
+scop_adjust_vphi (scop_p scop, gimple phi, edge true_e)
+{
+  unsigned i;
+
+  gcc_assert (gimple_phi_num_args (phi) == 2);
+
+  for (i = 0; i < gimple_phi_num_args (phi); i++)
+    if (gimple_phi_arg_edge (phi, i) == true_e)
+      {
+	tree true_arg, false_arg, before_scop_arg;
+	sbitmap visited;
+
+	true_arg = gimple_phi_arg_def (phi, i);
+	if (!SSA_NAME_IS_DEFAULT_DEF (true_arg))
+	  return;
+
+	false_arg = gimple_phi_arg_def (phi, i == 0 ? 1 : 0);
+	if (SSA_NAME_IS_DEFAULT_DEF (false_arg))
+	  return;
+
+	visited = sbitmap_alloc (last_basic_block);
+	sbitmap_zero (visited);
+	before_scop_arg = get_vdef_before_scop (scop, false_arg, visited);
+	gcc_assert (before_scop_arg != NULL_TREE);
+	SET_PHI_ARG_DEF (phi, i, before_scop_arg);
+	sbitmap_free (visited);
+      }
+}
+
 /* Adjusts the phi nodes in the block BB for variables defined in
    SCOP_REGION and used outside the SCOP_REGION.  The code generation
    moves SCOP_REGION in the else clause of an "if (1)" and generates
@@ -5214,7 +5290,10 @@ scop_adjust_phis_for_liveouts (scop_p sc
       gimple phi = gsi_stmt (si);
 
       if (!is_gimple_reg (PHI_RESULT (phi)))
-	continue;
+	{
+	  scop_adjust_vphi (scop, phi, true_e);
+	  continue;
+	}
 
       for (i = 0; i < gimple_phi_num_args (phi); i++)
 	if (gimple_phi_arg_edge (phi, i) == false_e)
@@ -5396,9 +5475,6 @@ gloog (scop_p scop, struct clast_stmt *s
 
   recompute_all_dominators ();
   graphite_verify ();
-  cleanup_tree_cfg ();
-  recompute_all_dominators ();
-  graphite_verify ();
 }
 
 /* Returns the number of data references in SCOP.  */
@@ -6095,6 +6171,7 @@ graphite_transform_loops (void)
     }
 
   /* Cleanup.  */
+  cleanup_tree_cfg ();
   free_scops (current_scops);
   cloog_finalize ();
   free_original_copy_tables ();

  reply	other threads:[~2009-01-14 10:20 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06 19:31 [Bug middle-end/38431] New: [graphite] several ICEs with CP2K jv244 at cam dot ac dot uk
2008-12-09  8:44 ` [Bug middle-end/38431] " jv244 at cam dot ac dot uk
2008-12-09 19:43 ` jv244 at cam dot ac dot uk
2008-12-09 20:12 ` [Bug middle-end/38431] [graphite] several ICEs with CP2K (summery) grosser at gcc dot gnu dot org
2008-12-09 20:26 ` grosser at gcc dot gnu dot org
2008-12-09 21:03 ` jv244 at cam dot ac dot uk
2008-12-09 21:12 ` jv244 at cam dot ac dot uk
2008-12-10 22:34 ` jv244 at cam dot ac dot uk
2008-12-11 19:20 ` jv244 at cam dot ac dot uk
2008-12-11 20:20 ` [Bug middle-end/38431] [graphite] several ICEs with CP2K (summary) jv244 at cam dot ac dot uk
2008-12-11 21:42 ` jv244 at cam dot ac dot uk
2008-12-13  8:41 ` jv244 at cam dot ac dot uk
2008-12-14 15:56 ` dominiq at lps dot ens dot fr
2008-12-15 17:32 ` jv244 at cam dot ac dot uk
2008-12-15 19:08 ` jv244 at cam dot ac dot uk
2008-12-15 19:45 ` jv244 at cam dot ac dot uk
2009-01-07 19:07 ` jv244 at cam dot ac dot uk
2009-01-07 19:23 ` sebpop at gmail dot com
2009-01-07 20:52 ` jv244 at cam dot ac dot uk
2009-01-08 17:11 ` spop at gcc dot gnu dot org
2009-01-08 19:31 ` jv244 at cam dot ac dot uk
2009-01-08 19:53 ` sebpop at gmail dot com
2009-01-09  5:38 ` jv244 at cam dot ac dot uk
2009-01-09  6:16 ` jv244 at cam dot ac dot uk
2009-01-09  6:18 ` jv244 at cam dot ac dot uk
2009-01-11 12:30 ` jv244 at cam dot ac dot uk
2009-01-11 12:59 ` jv244 at cam dot ac dot uk
2009-01-11 13:42 ` sebpop at gmail dot com
2009-01-13 19:52   ` Sebastian Pop
2009-01-13 19:53 ` sebpop at gmail dot com
2009-01-13 20:33 ` jv244 at cam dot ac dot uk
2009-01-13 21:57   ` Sebastian Pop
2009-01-13 21:57 ` sebpop at gmail dot com
2009-01-14  6:49 ` jv244 at cam dot ac dot uk
2009-01-14 10:20   ` Sebastian Pop [this message]
2009-01-14 10:20 ` sebpop at gmail dot com
2009-01-14 10:51 ` jv244 at cam dot ac dot uk
2009-01-14 12:09 ` jv244 at cam dot ac dot uk
2009-01-14 14:35 ` spop at gcc dot gnu dot org
2009-01-14 14:36 ` spop at gcc dot gnu dot org
2009-01-14 21:11 ` spop at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cb9d34b20901140220n456d6a63x54904b00a39102c6@mail.gmail.com \
    --to=sebpop@gmail.com \
    --cc=gcc-bugs@gcc.gnu.org \
    --cc=gcc-bugzilla@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).