public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR69378
@ 2016-01-20 15:03 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2016-01-20 15:03 UTC (permalink / raw)
  To: gcc-patches


I am currently testing the following patch to fix PR69378 (another
fallout of the PR69117 fix).

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Richard.

2016-01-20  Richard Biener  <rguenther@suse.de>

        PR tree-optimization/69378
	* tree-ssa-sccvn.c (dominated_by_p_w_unex): New function.
	(set_ssa_val_to): Use it for dominance checks taking into
	account not executable edges.

Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c	(revision 232603)
--- gcc/tree-ssa-sccvn.c	(working copy)
*************** print_scc (FILE *out, vec<tree> scc)
*** 2969,2974 ****
--- 2969,3055 ----
    fprintf (out, "\n");
  }
  
+ /* Return true if BB1 is dominated by BB2 taking into account edges
+    that are not executable.  */
+ 
+ static bool
+ dominated_by_p_w_unex (basic_block bb1, basic_block bb2)
+ {
+   edge_iterator ei;
+   edge e;
+ 
+   if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
+     return true;
+ 
+   /* Before iterating we'd like to know if there exists a
+      (executable) path from bb2 to bb1 at all, if not we can
+      directly return false.  For now simply iterate once.  */
+ 
+   /* Iterate to the single executable bb1 predecessor.  */
+   if (EDGE_COUNT (bb1->preds) > 1)
+     {
+       edge prede = NULL;
+       FOR_EACH_EDGE (e, ei, bb1->preds)
+ 	if (e->flags & EDGE_EXECUTABLE)
+ 	  {
+ 	    if (prede)
+ 	      {
+ 		prede = NULL;
+ 		break;
+ 	      }
+ 	    prede = e;
+ 	  }
+       if (prede)
+ 	{
+ 	  bb1 = prede->src;
+ 
+ 	  /* Re-do the dominance check with changed bb1.  */
+ 	  if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
+ 	    return true;
+ 	}
+     }
+ 
+   /* Iterate to the single executable bb2 successor.  */
+   edge succe = NULL;
+   FOR_EACH_EDGE (e, ei, bb2->succs)
+     if (e->flags & EDGE_EXECUTABLE)
+       {
+ 	if (succe)
+ 	  {
+ 	    succe = NULL;
+ 	    break;
+ 	  }
+ 	succe = e;
+       }
+   if (succe)
+     {
+       /* Verify the reached block is only reached through succe.
+ 	 If there is only one edge we can spare us the dominator
+ 	 check and iterate directly.  */
+       if (EDGE_COUNT (succe->dest->preds) > 1)
+ 	{
+ 	  FOR_EACH_EDGE (e, ei, succe->dest->preds)
+ 	    if (e != succe
+ 		&& (e->flags & EDGE_EXECUTABLE))
+ 	      {
+ 		succe = NULL;
+ 		break;
+ 	      }
+ 	}
+       if (succe)
+ 	{
+ 	  bb2 = succe->dest;
+ 
+ 	  /* Re-do the dominance check with changed bb2.  */
+ 	  if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
+ 	    return true;
+ 	}
+     }
+ 
+   /* We could now iterate updating bb1 / bb2.  */
+   return false;
+ }
+ 
  /* Set the value number of FROM to TO, return true if it has changed
     as a result.  */
  
*************** set_ssa_val_to (tree from, tree to)
*** 3046,3060 ****
  	      && SSA_NAME_RANGE_INFO (to))
  	    {
  	      if (SSA_NAME_IS_DEFAULT_DEF (to)
! 		  || dominated_by_p (CDI_DOMINATORS,
! 				     gimple_bb (SSA_NAME_DEF_STMT (from)),
! 				     gimple_bb (SSA_NAME_DEF_STMT (to))))
  		/* Keep the info from the dominator.  */
  		;
  	      else if (SSA_NAME_IS_DEFAULT_DEF (from)
! 		       || dominated_by_p (CDI_DOMINATORS,
! 					  gimple_bb (SSA_NAME_DEF_STMT (to)),
! 					  gimple_bb (SSA_NAME_DEF_STMT (from))))
  		{
  		  /* Save old info.  */
  		  if (! VN_INFO (to)->info.range_info)
--- 3127,3141 ----
  	      && SSA_NAME_RANGE_INFO (to))
  	    {
  	      if (SSA_NAME_IS_DEFAULT_DEF (to)
! 		  || dominated_by_p_w_unex
! 			(gimple_bb (SSA_NAME_DEF_STMT (from)),
! 			 gimple_bb (SSA_NAME_DEF_STMT (to))))
  		/* Keep the info from the dominator.  */
  		;
  	      else if (SSA_NAME_IS_DEFAULT_DEF (from)
! 		       || dominated_by_p_w_unex
! 			    (gimple_bb (SSA_NAME_DEF_STMT (to)),
! 			     gimple_bb (SSA_NAME_DEF_STMT (from))))
  		{
  		  /* Save old info.  */
  		  if (! VN_INFO (to)->info.range_info)
*************** set_ssa_val_to (tree from, tree to)
*** 3076,3090 ****
  		   && SSA_NAME_PTR_INFO (to))
  	    {
  	      if (SSA_NAME_IS_DEFAULT_DEF (to)
! 		  || dominated_by_p (CDI_DOMINATORS,
! 				     gimple_bb (SSA_NAME_DEF_STMT (from)),
! 				     gimple_bb (SSA_NAME_DEF_STMT (to))))
  		/* Keep the info from the dominator.  */
  		;
  	      else if (SSA_NAME_IS_DEFAULT_DEF (from)
! 		       || dominated_by_p (CDI_DOMINATORS,
! 					  gimple_bb (SSA_NAME_DEF_STMT (to)),
! 					  gimple_bb (SSA_NAME_DEF_STMT (from))))
  		{
  		  /* Save old info.  */
  		  if (! VN_INFO (to)->info.ptr_info)
--- 3157,3171 ----
  		   && SSA_NAME_PTR_INFO (to))
  	    {
  	      if (SSA_NAME_IS_DEFAULT_DEF (to)
! 		  || dominated_by_p_w_unex
! 			(gimple_bb (SSA_NAME_DEF_STMT (from)),
! 			 gimple_bb (SSA_NAME_DEF_STMT (to))))
  		/* Keep the info from the dominator.  */
  		;
  	      else if (SSA_NAME_IS_DEFAULT_DEF (from)
! 		       || dominated_by_p_w_unex
! 			    (gimple_bb (SSA_NAME_DEF_STMT (to)),
! 			     gimple_bb (SSA_NAME_DEF_STMT (from))))
  		{
  		  /* Save old info.  */
  		  if (! VN_INFO (to)->info.ptr_info)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-01-20 15:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 15:03 [PATCH] Fix PR69378 Richard Biener

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).