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]

[graphite] Fix again PR38953: loop closed SSA not maintained by graphite code generation


Hi,

The problem with the previous approach to solve this bug is that it
broke povray from SPEC2006.

The graphite code generation places the old code in a condition

if (1)
  new_code;
  empty_bb;
else
  original_code;
  empty_bb;
endif

Unfortunately the utility that builds the condition has to insert
empty basic blocks on the then and else edges, as there is no way to
build two edges with similar source and destinations.  When inserting
the code of the original code in the else branch, the empty basic
block remains along, and the code that is after the endif is one empty
basic block away.

This patch reverts the previous fix that consisted of splitting the
exit block containing the close loop phi nodes and adding the close
loop phi nodes to the scop.  The problem is when the block that
contains the close loop phi nodes has more than a predecessor, as
there are other phi nodes that stand for something different than a
loop close phi.  These phi nodes are then moved inside the else region
that will disappear after a cfg cleanup, making the generated code
invalid.

The fix that this patch implements is to remove the empty basic block
from the else branch, making the original phi nodes following the
original_code valid loop closed phi nodes.

The patch passed regstrap on amd64-linux with the graphite branch and
fixes the povray benchmark from Cpu2006.  Okay for trunk?

Thanks,
Sebastian Pop
--
AMD - GNU Tools
	* graphite.c (if_region_set_false_region): After moving a region 
	in the false branch of a condition, remove the empty dummy basic block.
	(gloog): Remove wrong fix for PR38953.

Index: graphite.c
===================================================================
--- graphite.c	(revision 143936)
+++ graphite.c	(working copy)
@@ -4993,6 +4993,7 @@ if_region_set_false_region (ifsese if_re
 {
   basic_block condition = if_region_get_condition_block (if_region);
   edge false_edge = get_false_edge_from_guard_bb (condition);
+  basic_block dummy = false_edge->dest;
   edge entry_region = SESE_ENTRY (region);
   edge exit_region = SESE_EXIT (region);
   basic_block before_region = entry_region->src;
@@ -5007,11 +5008,13 @@ if_region_set_false_region (ifsese if_re
   redirect_edge_pred (entry_region, condition);
   redirect_edge_pred (exit_region, before_region);
   redirect_edge_pred (false_edge, last_in_region);
+  redirect_edge_succ (false_edge, single_succ (dummy));
+  delete_basic_block (dummy);
 
   exit_region->flags = EDGE_FALLTHRU;
   recompute_all_dominators ();
 
-  SESE_EXIT (region) = single_succ_edge (false_edge->dest);
+  SESE_EXIT (region) = false_edge;
   if_region->false_region = region;
 
   if (slot)
@@ -5405,16 +5408,6 @@ gloog (scop_p scop, struct clast_stmt *s
   loop_p context_loop;
   ifsese if_region = NULL;
 
-  /* To maintain the loop closed SSA form, we have to keep the phi
-     nodes after the last loop in the scop.  */
-  if (loop_depth (SESE_EXIT (SCOP_REGION (scop))->dest->loop_father)
-      != loop_depth (SESE_EXIT (SCOP_REGION (scop))->src->loop_father))
-    {
-      basic_block bb = SESE_EXIT (SCOP_REGION (scop))->dest;
-      SESE_EXIT (SCOP_REGION (scop)) = split_block_after_labels (bb);
-      pointer_set_insert (SESE_REGION_BBS (SCOP_REGION (scop)), bb);
-    }
-
   recompute_all_dominators ();
   graphite_verify ();
   if_region = move_sese_in_condition (SCOP_REGION (scop));

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