public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH][1/2] Alternate fix for PR81403
Date: Wed, 22 Nov 2017 09:06:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.20.1711220958590.12252@zhemvz.fhfr.qr> (raw)


I had the need to analyze the PR81403 failure again and figured the real
cause and prepared a patch for this (the original fix still keeps some
issues latent I think).

This is cleanups that make it easier to debug PRE issues.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-11-22  Richard Biener  <rguenther@suse.de>

	* gimple-iterator.c (gimple_find_edge_insert_loc): Ignore
	fake edges to exit when looking for a place to insert.
	* tree-ssa-pre.c (clear_expression_ids): Inline into callers
	and remove.
	(insert_into_preds_of_block): Commit edge insertion immediately,
	assert that doesn't require new BBs.
	(fini_pre): Release expressions.
	(pass_pre::execute): Shuffle things around a bit, if the fn
	is too large do not compute AVAIL either as this is really the
	quadratic bit.

Index: gcc/gimple-iterator.c
===================================================================
--- gcc/gimple-iterator.c	(revision 254995)
+++ gcc/gimple-iterator.c	(working copy)
@@ -763,7 +763,12 @@ gimple_find_edge_insert_loc (edge e, gim
      Except for the entry block.  */
   src = e->src;
   if ((e->flags & EDGE_ABNORMAL) == 0
-      && single_succ_p (src)
+      && (single_succ_p (src)
+	  /* Do not count a fake edge as successor as added to infinite
+	     loops by connect_infinite_loops_to_exit.  */
+	  || (EDGE_COUNT (src->succs) == 2
+	      && (EDGE_SUCC (src, 0)->flags & EDGE_FAKE
+		  || EDGE_SUCC (src, 1)->flags & EDGE_FAKE)))
       && src != ENTRY_BLOCK_PTR_FOR_FN (cfun))
     {
       *gsi = gsi_last_bb (src);
Index: gcc/tree-ssa-pre.c
===================================================================
--- gcc/tree-ssa-pre.c	(revision 254995)
+++ gcc/tree-ssa-pre.c	(working copy)
@@ -400,15 +400,6 @@ expression_for_id (unsigned int id)
   return expressions[id];
 }
 
-/* Free the expression id field in all of our expressions,
-   and then destroy the expressions array.  */
-
-static void
-clear_expression_ids (void)
-{
-  expressions.release ();
-}
-
 static object_allocator<pre_expr_d> pre_expr_pool ("pre_expr nodes");
 
 /* Given an SSA_NAME NAME, get or create a pre_expr to represent it.  */
@@ -1331,7 +1322,6 @@ get_representative_for (const pre_expr e
 }
 
 
-
 static pre_expr
 phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2,
 	       basic_block pred, basic_block phiblock);
@@ -3004,7 +2994,8 @@ insert_into_preds_of_block (basic_block
       gcc_assert (!(pred->flags & EDGE_ABNORMAL));
       if (!gimple_seq_empty_p (stmts))
 	{
-	  gsi_insert_seq_on_edge (pred, stmts);
+	  basic_block new_bb = gsi_insert_seq_on_edge_immediate (pred, stmts);
+	  gcc_assert (! new_bb);
 	  insertions = true;
 	}
       if (!builtexpr)
@@ -4127,6 +4118,7 @@ static void
 fini_pre ()
 {
   value_expressions.release ();
+  expressions.release ();
   BITMAP_FREE (inserted_exprs);
   bitmap_obstack_release (&grand_bitmap_obstack);
   bitmap_set_pool.release ();
@@ -4181,22 +4173,21 @@ pass_pre::execute (function *fun)
      loop_optimizer_init may create new phis, etc.  */
   loop_optimizer_init (LOOPS_NORMAL);
   split_critical_edges ();
+  scev_initialize ();
 
   run_scc_vn (VN_WALK);
 
   init_pre ();
-  scev_initialize ();
-
-  /* Collect and value number expressions computed in each basic block.  */
-  compute_avail ();
 
   /* Insert can get quite slow on an incredibly large number of basic
      blocks due to some quadratic behavior.  Until this behavior is
      fixed, don't run it when he have an incredibly large number of
      bb's.  If we aren't going to run insert, there is no point in
-     computing ANTIC, either, even though it's plenty fast.  */
+     computing ANTIC, either, even though it's plenty fast nor do
+     we require AVAIL.  */
   if (n_basic_blocks_for_fn (fun) < 4000)
     {
+      compute_avail ();
       compute_antic ();
       insert ();
     }
@@ -4211,19 +4202,19 @@ pass_pre::execute (function *fun)
      not keeping virtual operands up-to-date.  */
   gcc_assert (!need_ssa_update_p (fun));
 
-  /* Remove all the redundant expressions.  */
-  todo |= vn_eliminate (inserted_exprs);
-
   statistics_counter_event (fun, "Insertions", pre_stats.insertions);
   statistics_counter_event (fun, "PA inserted", pre_stats.pa_insert);
   statistics_counter_event (fun, "HOIST inserted", pre_stats.hoist_insert);
   statistics_counter_event (fun, "New PHIs", pre_stats.phis);
 
-  clear_expression_ids ();
+  /* Remove all the redundant expressions.  */
+  todo |= vn_eliminate (inserted_exprs);
 
-  scev_finalize ();
   remove_dead_inserted_code ();
+
   fini_pre ();
+
+  scev_finalize ();
   loop_optimizer_finalize ();
 
   /* Restore SSA info before tail-merging as that resets it as well.  */

                 reply	other threads:[~2017-11-22  9:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=alpine.LSU.2.20.1711220958590.12252@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@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).