public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Avoid doing superfluous work in force_nonfallthru
@ 2011-04-11 21:55 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2011-04-11 21:55 UTC (permalink / raw)
  To: gcc-patches

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

The new force_nonfallthru was modelled on redirect_edge_and_branch_force, but 
this means that it is doing superfluous work when the edge can be turned into 
a non-fallthru edge without creating a new basic block.

Fixed thusly, bootstrapped/regested on x86_64-suse-linux, applied.


2011-04-11  Eric Botcazou  <ebotcazou@adacore.com>

        * cfghooks.c (redirect_edge_and_branch_force): Localize variable.
	(force_nonfallthru): Do not alter the loop nest if no basic block
	was created.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 2296 bytes --]

Index: cfghooks.c
===================================================================
--- cfghooks.c	(revision 172247)
+++ cfghooks.c	(working copy)
@@ -388,7 +388,6 @@ basic_block
 redirect_edge_and_branch_force (edge e, basic_block dest)
 {
   basic_block ret, src = e->src;
-  struct loop *loop;
 
   if (!cfg_hooks->redirect_edge_and_branch_force)
     internal_error ("%s does not support redirect_edge_and_branch_force",
@@ -398,6 +397,7 @@ redirect_edge_and_branch_force (edge e,
     rescan_loop_exit (e, false, true);
 
   ret = cfg_hooks->redirect_edge_and_branch_force (e, dest);
+
   if (ret != NULL && dom_info_available_p (CDI_DOMINATORS))
     set_immediate_dominator (CDI_DOMINATORS, ret, src);
 
@@ -405,8 +405,9 @@ redirect_edge_and_branch_force (edge e,
     {
       if (ret != NULL)
 	{
-	  loop = find_common_loop (single_pred (ret)->loop_father,
-				   single_succ (ret)->loop_father);
+	  struct loop *loop
+	    = find_common_loop (single_pred (ret)->loop_father,
+				single_succ (ret)->loop_father);
 	  add_bb_to_loop (ret, loop);
 	}
       else if (find_edge (src, dest) == e)
@@ -882,30 +883,26 @@ tidy_fallthru_edges (void)
 basic_block
 force_nonfallthru (edge e)
 {
-  basic_block ret, src = e->src, dest = e->dest;
-  struct loop *loop;
+  basic_block ret, src = e->src;
 
   if (!cfg_hooks->force_nonfallthru)
     internal_error ("%s does not support force_nonfallthru",
 		    cfg_hooks->name);
 
-  if (current_loops != NULL)
-    rescan_loop_exit (e, false, true);
-
   ret = cfg_hooks->force_nonfallthru (e);
-  if (ret != NULL && dom_info_available_p (CDI_DOMINATORS))
-    set_immediate_dominator (CDI_DOMINATORS, ret, src);
-
-  if (current_loops != NULL)
+  if (ret != NULL)
     {
-      if (ret != NULL)
+      if (dom_info_available_p (CDI_DOMINATORS))
+	set_immediate_dominator (CDI_DOMINATORS, ret, src);
+
+      if (current_loops != NULL)
 	{
-	  loop = find_common_loop (single_pred (ret)->loop_father,
-				   single_succ (ret)->loop_father);
+	  struct loop *loop
+	    = find_common_loop (single_pred (ret)->loop_father,
+				single_succ (ret)->loop_father);
+	  rescan_loop_exit (e, false, true);
 	  add_bb_to_loop (ret, loop);
 	}
-      else if (find_edge (src, dest) == e)
-	rescan_loop_exit (e, true, false);
     }
 
   return ret;

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

only message in thread, other threads:[~2011-04-11 21:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-11 21:55 Avoid doing superfluous work in force_nonfallthru Eric Botcazou

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