This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR63196, ensure loops are fixed before inlining


On Mon, 8 Sep 2014, Richard Biener wrote:

> 
> The following patch makes sure we don't inline / copy a CFG with
> loops needing fixups.  In the particular case function versioning
> after IPA-CP made a CFG portion dead, removing a loop.
> 
> The patch also makes the bogus loop removal detection unconditional
> as gengtype doesn't seem to be able to handle preprocessor conditional
> fields.
> 
> Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

While I committed the PR63204 parts already the PR63196 change
had fallout in simd vect cloning which manages to get loop
creation wrong, putting the return block into the inner loop.

Fixed like the following.

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

Richard.

2014-09-08  Richard Biener  <rguenther@suse.de>

	PR ipa/63196
	* tree-inline.c (copy_loops): The source loop header should
	always be non-NULL.
	(tree_function_versioning): If loops need fixup after removing
	unreachable blocks fix them.
	* omp-low.c (simd_clone_adjust): Do not add incr block to
	loop under construction.

Index: gcc/tree-inline.c
===================================================================
--- gcc/tree-inline.c	(revision 215008)
+++ gcc/tree-inline.c	(working copy)
@@ -2376,11 +2406,8 @@ copy_loops (copy_body_data *id,
 
 	  /* Assign the new loop its header and latch and associate
 	     those with the new loop.  */
-	  if (src_loop->header != NULL)
-	    {
-	      dest_loop->header = (basic_block)src_loop->header->aux;
-	      dest_loop->header->loop_father = dest_loop;
-	    }
+	  dest_loop->header = (basic_block)src_loop->header->aux;
+	  dest_loop->header->loop_father = dest_loop;
 	  if (src_loop->latch != NULL)
 	    {
 	      dest_loop->latch = (basic_block)src_loop->latch->aux;
@@ -5536,6 +5567,11 @@ tree_function_versioning (tree old_decl,
   delete_unreachable_blocks_update_callgraph (&id);
   if (id.dst_node->definition)
     cgraph_edge::rebuild_references ();
+  if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
+    {
+      calculate_dominance_info (CDI_DOMINATORS);
+      fix_loop_structure (NULL);
+    }
   update_ssa (TODO_update_ssa);
 
   /* After partial cloning we need to rescale frequencies, so they are
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c	(revision 215008)
+++ gcc/omp-low.c	(working copy)
@@ -11900,6 +11900,7 @@ simd_clone_adjust (struct cgraph_node *n
      iteration increment and the condition/branch.  */
   basic_block orig_exit = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), 0)->src;
   basic_block incr_bb = create_empty_bb (orig_exit);
+  add_bb_to_loop (incr_bb, body_bb->loop_father);
   /* The succ of orig_exit was EXIT_BLOCK_PTR_FOR_FN (cfun), with an empty
      flag.  Set it now to be a FALLTHRU_EDGE.  */
   gcc_assert (EDGE_COUNT (orig_exit->succs) == 1);
@@ -11924,7 +11925,6 @@ simd_clone_adjust (struct cgraph_node *n
   loop->safelen = node->simdclone->simdlen;
   loop->force_vectorize = true;
   loop->header = body_bb;
-  add_bb_to_loop (incr_bb, loop);
 
   /* Branch around the body if the mask applies.  */
   if (node->simdclone->inbranch)
@@ -11965,7 +11965,7 @@ simd_clone_adjust (struct cgraph_node *n
   gsi_insert_after (&gsi, g, GSI_CONTINUE_LINKING);
   e = split_block (incr_bb, gsi_stmt (gsi));
   basic_block latch_bb = e->dest;
-  basic_block new_exit_bb = e->dest;
+  basic_block new_exit_bb;
   new_exit_bb = split_block (latch_bb, NULL)->dest;
   loop->latch = latch_bb;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]