Patchwork cfg_layout_merge_blocks cleanup

login
register
mail settings
Submitter Jakub Jelinek
Date March 5, 2012, 11:14 a.m.
Message ID <20120305111403.GT18768@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/144659/
State New
Headers show

Comments

Jakub Jelinek - March 5, 2012, 11:14 a.m.
Hi!

Here is a tiny cleanup, written as part of PR52139 fix.
Bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-03-05  Jakub Jelinek  <jakub@redhat.com>

	* cfgrtl.c (cfg_layout_merge_blocks): Cleanup.


	Jakub
Richard Guenther - March 5, 2012, 11:15 a.m.
On Mon, 5 Mar 2012, Jakub Jelinek wrote:

> Hi!
> 
> Here is a tiny cleanup, written as part of PR52139 fix.
> Bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

Ok.

Thanks,
Richard.

> 2012-03-05  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* cfgrtl.c (cfg_layout_merge_blocks): Cleanup.
> 
> --- gcc/cfgrtl.c.jj	2012-02-07 16:05:47.977533716 +0100
> +++ gcc/cfgrtl.c	2012-02-07 17:03:52.925956927 +0100
> @@ -2818,6 +2818,7 @@ static void
>  cfg_layout_merge_blocks (basic_block a, basic_block b)
>  {
>    bool forwarder_p = (b->flags & BB_FORWARDER_BLOCK) != 0;
> +  rtx insn;
>  
>    gcc_checking_assert (cfg_layout_can_merge_blocks_p (a, b));
>  
> @@ -2883,40 +2884,28 @@ cfg_layout_merge_blocks (basic_block a,
>    /* In the case basic blocks are not adjacent, move them around.  */
>    if (NEXT_INSN (BB_END (a)) != BB_HEAD (b))
>      {
> -      rtx first = unlink_insn_chain (BB_HEAD (b), BB_END (b));
> +      insn = unlink_insn_chain (BB_HEAD (b), BB_END (b));
>  
> -      emit_insn_after_noloc (first, BB_END (a), a);
> -      /* Skip possible DELETED_LABEL insn.  */
> -      if (!NOTE_INSN_BASIC_BLOCK_P (first))
> -	first = NEXT_INSN (first);
> -      gcc_assert (NOTE_INSN_BASIC_BLOCK_P (first));
> -      BB_HEAD (b) = NULL;
> -
> -      /* emit_insn_after_noloc doesn't call df_insn_change_bb.
> -         We need to explicitly call. */
> -      update_bb_for_insn_chain (NEXT_INSN (first),
> -				BB_END (b),
> -				a);
> -
> -      delete_insn (first);
> +      emit_insn_after_noloc (insn, BB_END (a), a);
>      }
>    /* Otherwise just re-associate the instructions.  */
>    else
>      {
> -      rtx insn;
> -
> -      update_bb_for_insn_chain (BB_HEAD (b), BB_END (b), a);
> -
>        insn = BB_HEAD (b);
> -      /* Skip possible DELETED_LABEL insn.  */
> -      if (!NOTE_INSN_BASIC_BLOCK_P (insn))
> -	insn = NEXT_INSN (insn);
> -      gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
> -      BB_HEAD (b) = NULL;
>        BB_END (a) = BB_END (b);
> -      delete_insn (insn);
>      }
>  
> +  /* emit_insn_after_noloc doesn't call df_insn_change_bb.
> +     We need to explicitly call. */
> +  update_bb_for_insn_chain (insn, BB_END (b), a);
> +
> +  /* Skip possible DELETED_LABEL insn.  */
> +  if (!NOTE_INSN_BASIC_BLOCK_P (insn))
> +    insn = NEXT_INSN (insn);
> +  gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
> +  BB_HEAD (b) = NULL;
> +  delete_insn (insn);
> +
>    df_bb_delete (b->index);
>  
>    /* Possible tablejumps and barriers should appear after the block.  */
> 
> 	Jakub
> 
>

Patch

--- gcc/cfgrtl.c.jj	2012-02-07 16:05:47.977533716 +0100
+++ gcc/cfgrtl.c	2012-02-07 17:03:52.925956927 +0100
@@ -2818,6 +2818,7 @@  static void
 cfg_layout_merge_blocks (basic_block a, basic_block b)
 {
   bool forwarder_p = (b->flags & BB_FORWARDER_BLOCK) != 0;
+  rtx insn;
 
   gcc_checking_assert (cfg_layout_can_merge_blocks_p (a, b));
 
@@ -2883,40 +2884,28 @@  cfg_layout_merge_blocks (basic_block a,
   /* In the case basic blocks are not adjacent, move them around.  */
   if (NEXT_INSN (BB_END (a)) != BB_HEAD (b))
     {
-      rtx first = unlink_insn_chain (BB_HEAD (b), BB_END (b));
+      insn = unlink_insn_chain (BB_HEAD (b), BB_END (b));
 
-      emit_insn_after_noloc (first, BB_END (a), a);
-      /* Skip possible DELETED_LABEL insn.  */
-      if (!NOTE_INSN_BASIC_BLOCK_P (first))
-	first = NEXT_INSN (first);
-      gcc_assert (NOTE_INSN_BASIC_BLOCK_P (first));
-      BB_HEAD (b) = NULL;
-
-      /* emit_insn_after_noloc doesn't call df_insn_change_bb.
-         We need to explicitly call. */
-      update_bb_for_insn_chain (NEXT_INSN (first),
-				BB_END (b),
-				a);
-
-      delete_insn (first);
+      emit_insn_after_noloc (insn, BB_END (a), a);
     }
   /* Otherwise just re-associate the instructions.  */
   else
     {
-      rtx insn;
-
-      update_bb_for_insn_chain (BB_HEAD (b), BB_END (b), a);
-
       insn = BB_HEAD (b);
-      /* Skip possible DELETED_LABEL insn.  */
-      if (!NOTE_INSN_BASIC_BLOCK_P (insn))
-	insn = NEXT_INSN (insn);
-      gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
-      BB_HEAD (b) = NULL;
       BB_END (a) = BB_END (b);
-      delete_insn (insn);
     }
 
+  /* emit_insn_after_noloc doesn't call df_insn_change_bb.
+     We need to explicitly call. */
+  update_bb_for_insn_chain (insn, BB_END (b), a);
+
+  /* Skip possible DELETED_LABEL insn.  */
+  if (!NOTE_INSN_BASIC_BLOCK_P (insn))
+    insn = NEXT_INSN (insn);
+  gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
+  BB_HEAD (b) = NULL;
+  delete_insn (insn);
+
   df_bb_delete (b->index);
 
   /* Possible tablejumps and barriers should appear after the block.  */