public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
@ 2004-07-21  1:24 Richard Sandiford
  2004-07-21  1:46 ` Richard Sandiford
  2004-07-21 17:27 ` Richard Sandiford
  0 siblings, 2 replies; 8+ messages in thread
From: Richard Sandiford @ 2004-07-21  1:24 UTC (permalink / raw)
  To: gcc-patches

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

The following testcase:

    void foo (int a, int b, int c, int d, int e, int *f)
    {
      if (a == 0)
        if (b == 0)
          if (c == 0)
            if (d == 0)
              {
                *f = e;
                return;
              }
      *f = e;
      return;
    }

ICEs at -O2 on mips targets.  This happens both on mainline and
3.4 branch, but not 3.3.

As expected, crossjumping unifies the duplicate "*f = e" blocks,
leaving rtl like:

    if d == 0 then goto LABEL
    ;; end of block B1

    ;; start of block B2
    ;; end of block B2

    ;; start of block B3
    LABEL:

cleanup_cfg() (specifically try_simplify_condjump()) then deletes
the "if d == 0" branch, giving us:

    ;; start of block B1
    ;; end of block B1

    ;; start of block B3
    LABEL:

Now it looks like cleanup_cfg() is supposed to iterate until all such
jumps have been simplified, but it doesn't.  This is because it uses
a cache (the bb aux field) to detect forwarder blocks, and this cache
is not updated after B1 has been simplified.  Thus we only eliminate
one such branch for each call to cleanup_cfg().

The first patch below fixes that, and cures the ICE.  But to finish the
story... the task of cleaning up the final "a == 0" branch is left to:

    cleanup_cfg (CLEANUP_CFGLAYOUT);

called from cfg_layout_initialize(), itself called from
reorder_basic_blocks().  Now this call doesn't update the liveness
information, so "a" is still marked as live after all uses have been
deleted.  This causes the usual verify_local_live_at_start failure
during scheduling.

CLEANUP_CFGLAYOUT is clearly capable of deleting register uses, so I
assume that we should use CLEANUP_UPDATE_LIFE when liveness information
needs to be kept up to date.  That's what the second patch does, and it
also fixes the ICE (independently of the first).

The second patch has to touch other users of cfglayout as well:

   1) tracer:
        - called once before flow1, where CLEANUP_UPDATE_LIFE isn't needed
        - called once during bbro, where C_U_L is needed.

   2) reorder_basic_blocks
        - called once during bbro, where C_U_L is needed.
        - called once during stack, where C_U_L isn't needed.

   3) partition_hot_and_cold_blocks
        - called after flow1, but liveness info is recomputed immedately
          afterwards, so I don't think C_U_L is needed.

   4) thread_prologue_and_epilogue_insns
        - called between reload and flow2, C_U_L isn't needed.

   5) loop2:
        - before flow1, C_U_L isn't needed.

Slightly different patches are needed for mainline and branch.
The mainline versions have been bootstrapped & regression tested on
i686-pc-linux-gnu.  I'm testing the 3.4 patches on mips*-linux-gnu
targets now.

Assuming the 3.4 tests pass, are both patches OK for mainline and
branch?  Or would it be better to just apply the first patch to branch?

Richard


[-- Attachment #2: 16643-1-mainline.diff --]
[-- Type: text/plain, Size: 691 bytes --]

	* cfgcleanup.c (try_simplify_condjump): Call update_forwarder_flag
	after simplifying the jump.
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.121
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.121 cfgcleanup.c
--- cfgcleanup.c	17 Jul 2004 00:31:05 -0000	1.121
+++ cfgcleanup.c	20 Jul 2004 13:24:23 -0000
@@ -187,6 +187,7 @@ try_simplify_condjump (basic_block cbran
   /* Delete the block with the unconditional jump, and clean up the mess.  */
   delete_basic_block (jump_block);
   tidy_fallthru_edge (cbranch_jump_edge);
+  update_forwarder_flag (cbranch_block);
 
   return true;
 }

[-- Attachment #3: 16643-1-branch.diff --]
[-- Type: text/plain, Size: 728 bytes --]

	* cfgcleanup.c (try_simplify_condjump): Call update_forwarder_flag
	after simplifying the jump.
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.99.2.5
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.99.2.5 cfgcleanup.c
--- cfgcleanup.c	6 Mar 2004 01:24:08 -0000	1.99.2.5
+++ cfgcleanup.c	20 Jul 2004 13:46:43 -0000
@@ -196,6 +196,7 @@ try_simplify_condjump (basic_block cbran
   /* Delete the block with the unconditional jump, and clean up the mess.  */
   delete_block (jump_block);
   tidy_fallthru_edge (cbranch_jump_edge, cbranch_block, cbranch_dest_block);
+  update_forwarder_flag (cbranch_block);
 
   return true;
 }

[-- Attachment #4: 16643-2-mainline.diff --]
[-- Type: text/plain, Size: 8195 bytes --]

	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
	(partition_hot_cold_basic_blocks): Pass 0 to cfg_layout_initialize.
	* function.c (thread_prologue_and_epilogue_insns): Likewise.
	* rtl.h (tracer): Add a flags parameter.
	* tracer.c (tracer): Pass it to cfg_layout_initialise.
	* passes.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
	(rest_of_handle_reorder_blocks): Update calls to tracer and
	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
	(rest_of_handle_tracer): Pass 0 to tracer.
	(rest_of_handle_loop2): Pass 0 to cfg_layout_initialize.
Index: cfglayout.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.h,v
retrieving revision 1.14
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.14 cfglayout.h
--- cfglayout.h	3 Jun 2004 15:01:08 -0000	1.14
+++ cfglayout.h	20 Jul 2004 13:38:04 -0000
@@ -25,7 +25,7 @@ #define GCC_CFGLAYOUT_H
 
 extern rtx cfg_layout_function_footer;
 
-extern void cfg_layout_initialize (void);
+extern void cfg_layout_initialize (unsigned int);
 extern void cfg_layout_finalize (void);
 extern void insn_locators_initialize (void);
 extern void reemit_insn_block_notes (void);
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.66
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.66 cfglayout.c
--- cfglayout.c	9 Jul 2004 03:29:26 -0000	1.66
+++ cfglayout.c	20 Jul 2004 13:38:07 -0000
@@ -1137,7 +1137,7 @@ cfg_layout_duplicate_bb (basic_block bb)
    CFG layout changes.  It keeps LOOPS up-to-date if not null.  */
 
 void
-cfg_layout_initialize (void)
+cfg_layout_initialize (unsigned int flags)
 {
   basic_block bb;
 
@@ -1152,7 +1152,7 @@ cfg_layout_initialize (void)
 
   record_effective_endpoints ();
 
-  cleanup_cfg (CLEANUP_CFGLAYOUT);
+  cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
 
 /* Splits superblocks.  */
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.201
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.201 basic-block.h
--- basic-block.h	16 Jul 2004 22:28:27 -0000	1.201
+++ basic-block.h	20 Jul 2004 13:38:08 -0000
@@ -677,7 +677,7 @@ extern bool inside_basic_block_p (rtx);
 extern bool control_flow_insn_p (rtx);
 
 /* In bb-reorder.c */
-extern void reorder_basic_blocks (void);
+extern void reorder_basic_blocks (unsigned int);
 extern void partition_hot_cold_basic_blocks (void);
 
 /* In cfg.c */
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.76
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.76 bb-reorder.c
--- bb-reorder.c	9 Jul 2004 03:29:25 -0000	1.76
+++ bb-reorder.c	20 Jul 2004 13:38:12 -0000
@@ -1911,7 +1911,7 @@ fix_edges_for_rarely_executed_code (edge
 /* Reorder basic blocks.  The main entry point to this file.  */
 
 void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
 {
   int n_traces;
   int i;
@@ -1925,7 +1925,7 @@ reorder_basic_blocks (void)
 
   timevar_push (TV_REORDER_BLOCKS);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
 
   set_edge_can_fallthru_flag ();
   mark_dfs_back_edges ();
@@ -1999,7 +1999,7 @@ partition_hot_cold_basic_blocks (void)
   
   crossing_edges = xcalloc (max_edges, sizeof (edge));
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
   
   FOR_EACH_BB (cur_bb)
     if (cur_bb->index >= 0
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.558
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.558 function.c
--- function.c	16 Jul 2004 20:34:12 -0000	1.558
+++ function.c	20 Jul 2004 13:38:23 -0000
@@ -5257,7 +5257,7 @@ thread_prologue_and_epilogue_insns (rtx 
          use return.  Inserting a jump 'by hand' is extremely messy, so
 	 we take advantage of cfg_layout_finalize using
 	fixup_fallthru_exit_predecessor.  */
-      cfg_layout_initialize ();
+      cfg_layout_initialize (0);
       FOR_EACH_BB (cur_bb)
 	if (cur_bb->index >= 0 && cur_bb->next_bb->index >= 0)
 	  cur_bb->rbi->next = cur_bb->next_bb;
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.491
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.491 rtl.h
--- rtl.h	17 Jul 2004 00:31:07 -0000	1.491
+++ rtl.h	20 Jul 2004 13:38:31 -0000
@@ -2440,7 +2440,7 @@ extern void if_convert (int);
 extern void invert_br_probabilities (rtx);
 extern bool expensive_function_p (int);
 /* In tracer.c */
-extern void tracer (void);
+extern void tracer (unsigned int);
 
 /* In var-tracking.c */
 extern void variable_tracking_main (void);
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.19
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.19 tracer.c
--- tracer.c	13 May 2004 06:39:45 -0000	1.19
+++ tracer.c	20 Jul 2004 13:38:31 -0000
@@ -357,14 +357,14 @@ layout_superblocks (void)
 /* Main entry point to this file.  */
 
 void
-tracer (void)
+tracer (unsigned int flags)
 {
   if (n_basic_blocks <= 1)
     return;
 
   timevar_push (TV_TRACER);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
   mark_dfs_back_edges ();
   if (dump_file)
     dump_flow_info (dump_file);
Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.32
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.32 passes.c
--- passes.c	17 Jul 2004 18:08:10 -0000	2.32
+++ passes.c	20 Jul 2004 13:38:34 -0000
@@ -549,7 +549,7 @@ rest_of_handle_stack_regs (void)
 		       | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
 	  && (flag_reorder_blocks || flag_reorder_blocks_and_partition))
 	{
-	  reorder_basic_blocks ();
+	  reorder_basic_blocks (0);
 	  cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
 	}
     }
@@ -734,23 +734,22 @@ static void
 rest_of_handle_reorder_blocks (void)
 {
   bool changed;
+  unsigned int liveness_flags;
+
   open_dump_file (DFI_bbro, current_function_decl);
 
   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
      splitting possibly introduced more crossjumping opportunities.  */
-  changed = cleanup_cfg (CLEANUP_EXPENSIVE
-			 | (!HAVE_conditional_execution
-			    ? CLEANUP_UPDATE_LIFE : 0));
+  liveness_flags = (!HAVE_conditional_execution ? CLEANUP_UPDATE_LIFE : 0);
+  changed = cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
-    tracer ();
+    tracer (liveness_flags);
   if (flag_reorder_blocks || flag_reorder_blocks_and_partition)
-    reorder_basic_blocks ();
+    reorder_basic_blocks (liveness_flags);
   if (flag_reorder_blocks || flag_reorder_blocks_and_partition
       || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
-    changed |= cleanup_cfg (CLEANUP_EXPENSIVE
-			    | (!HAVE_conditional_execution
-			       ? CLEANUP_UPDATE_LIFE : 0));
+    changed |= cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   /* On conditional execution targets we can not update the life cheaply, so
      we deffer the updating to after both cleanups.  This may lose some cases
@@ -897,7 +896,7 @@ rest_of_handle_tracer (void)
   open_dump_file (DFI_tracer, current_function_decl);
   if (dump_file)
     dump_flow_info (dump_file);
-  tracer ();
+  tracer (0);
   cleanup_cfg (CLEANUP_EXPENSIVE);
   reg_scan (get_insns (), max_reg_num (), 0);
   close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
@@ -1353,7 +1352,7 @@ rest_of_handle_loop2 (void)
     dump_flow_info (dump_file);
 
   /* Initialize structures for layout changes.  */
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
 
   loops = loop_optimizer_init (dump_file);
 

[-- Attachment #5: 16643-2-branch.diff --]
[-- Type: text/plain, Size: 7334 bytes --]

	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
	* loop-init.c (loop_optimizer_init): Pass 0 to cfg_layout_initialize.
	* rtl.h (tracer): Add a flags parameter.
	* tracer.c (tracer): Pass it to cfg_layout_initialise.
	* toplev.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
	(rest_of_handle_reorder_blocks): Update calls to tracer and
	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
	(rest_of_handle_tracer): Pass 0 to tracer.
Index: cfglayout.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.h,v
retrieving revision 1.10
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.10 cfglayout.h
--- cfglayout.h	30 Dec 2003 10:40:51 -0000	1.10
+++ cfglayout.h	20 Jul 2004 13:39:48 -0000
@@ -35,7 +35,7 @@ typedef struct reorder_block_def
 
 extern rtx cfg_layout_function_footer;
 
-extern void cfg_layout_initialize (void);
+extern void cfg_layout_initialize (unsigned int);
 extern void cfg_layout_finalize (void);
 extern bool cfg_layout_can_duplicate_bb_p (basic_block);
 extern basic_block cfg_layout_duplicate_bb (basic_block, edge);
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.50
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.50 cfglayout.c
--- cfglayout.c	30 Dec 2003 10:40:50 -0000	1.50
+++ cfglayout.c	20 Jul 2004 13:39:49 -0000
@@ -1121,7 +1121,7 @@ cfg_layout_initialize_rbi (basic_block b
    CFG layout changes.  It keeps LOOPS up-to-date if not null.  */
 
 void
-cfg_layout_initialize (void)
+cfg_layout_initialize (unsigned int flags)
 {
   basic_block bb;
 
@@ -1137,7 +1137,7 @@ cfg_layout_initialize (void)
 
   record_effective_endpoints ();
 
-  cleanup_cfg (CLEANUP_CFGLAYOUT);
+  cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
 
 /* Splits superblocks.  */
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.186.4.3
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.186.4.3 basic-block.h
--- basic-block.h	30 Jan 2004 11:07:49 -0000	1.186.4.3
+++ basic-block.h	20 Jul 2004 13:39:50 -0000
@@ -606,7 +606,7 @@ extern bool inside_basic_block_p (rtx);
 extern bool control_flow_insn_p (rtx);
 
 /* In bb-reorder.c */
-extern void reorder_basic_blocks (void);
+extern void reorder_basic_blocks (unsigned int);
 
 /* In dominance.c */
 
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.63
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.63 bb-reorder.c
--- bb-reorder.c	20 Dec 2003 16:31:12 -0000	1.63
+++ bb-reorder.c	20 Jul 2004 13:39:51 -0000
@@ -1066,7 +1066,7 @@ get_uncond_jump_length (void)
 /* Reorder basic blocks.  The main entry point to this file.  */
 
 void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
 {
   int n_traces;
   int i;
@@ -1080,7 +1080,7 @@ reorder_basic_blocks (void)
 
   timevar_push (TV_REORDER_BLOCKS);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
 
   set_edge_can_fallthru_flag ();
   mark_dfs_back_edges ();
Index: loop-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-init.c,v
retrieving revision 1.7.4.1
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.7.4.1 loop-init.c
--- loop-init.c	2 Mar 2004 01:12:04 -0000	1.7.4.1
+++ loop-init.c	20 Jul 2004 13:39:51 -0000
@@ -39,7 +39,7 @@ loop_optimizer_init (FILE *dumpfile)
   edge e;
 
   /* Initialize structures for layout changes.  */
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
 
   /* Avoid annoying special cases of edges going to exit
      block.  */
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.448.4.5
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.448.4.5 rtl.h
--- rtl.h	21 Apr 2004 19:52:37 -0000	1.448.4.5
+++ rtl.h	20 Jul 2004 13:39:54 -0000
@@ -2334,6 +2334,6 @@ extern void if_convert (int);
 extern void invert_br_probabilities (rtx);
 extern bool expensive_function_p (int);
 /* In tracer.c */
-extern void tracer (void);
+extern void tracer (unsigned int);
 
 #endif /* ! GCC_RTL_H */
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.16
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.16 tracer.c
--- tracer.c	18 Dec 2003 17:07:24 -0000	1.16
+++ tracer.c	20 Jul 2004 13:39:55 -0000
@@ -357,14 +357,14 @@ layout_superblocks (void)
 /* Main entry point to this file.  */
 
 void
-tracer (void)
+tracer (unsigned int flags)
 {
   if (n_basic_blocks <= 1)
     return;
 
   timevar_push (TV_TRACER);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
   mark_dfs_back_edges ();
   if (rtl_dump_file)
     dump_flow_info (rtl_dump_file);
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.863.4.10
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.863.4.10 toplev.c
--- toplev.c	20 Feb 2004 08:40:49 -0000	1.863.4.10
+++ toplev.c	20 Jul 2004 13:39:59 -0000
@@ -2145,7 +2145,7 @@ rest_of_handle_stack_regs (tree decl, rt
 		       | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
 	  && flag_reorder_blocks)
 	{
-	  reorder_basic_blocks ();
+	  reorder_basic_blocks (0);
 	  cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
 	}
     }
@@ -2317,23 +2317,22 @@ static void
 rest_of_handle_reorder_blocks (tree decl, rtx insns)
 {
   bool changed;
+  unsigned int liveness_flags;
+
   open_dump_file (DFI_bbro, decl);
 
   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
      splitting possibly introduced more crossjumping opportunities.  */
-  changed = cleanup_cfg (CLEANUP_EXPENSIVE
-			 | (!HAVE_conditional_execution
-			    ? CLEANUP_UPDATE_LIFE : 0));
+  liveness_flags = (!HAVE_conditional_execution ? CLEANUP_UPDATE_LIFE : 0);
+  changed = cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
-    tracer ();
+    tracer (liveness_flags);
   if (flag_reorder_blocks)
-    reorder_basic_blocks ();
+    reorder_basic_blocks (liveness_flags);
   if (flag_reorder_blocks
       || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
-    changed |= cleanup_cfg (CLEANUP_EXPENSIVE
-			    | (!HAVE_conditional_execution
-			       ? CLEANUP_UPDATE_LIFE : 0));
+    changed |= cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   /* On conditional execution targets we can not update the life cheaply, so
      we deffer the updating to after both cleanups.  This may lose some cases
@@ -2423,7 +2422,7 @@ rest_of_handle_tracer (tree decl, rtx in
   open_dump_file (DFI_tracer, decl);
   if (rtl_dump_file)
     dump_flow_info (rtl_dump_file);
-  tracer ();
+  tracer (0);
   cleanup_cfg (CLEANUP_EXPENSIVE);
   reg_scan (insns, max_reg_num (), 0);
   close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: 16643.c --]
[-- Type: text/x-csrc, Size: 206 bytes --]

/* PR rtl-optimization/16643 */
void foo (int a, int b, int c, int d, int e, int *f)
{
  if (a == 0)
    if (b == 0)
      if (c == 0)
	if (d == 0)
	  {
	    *f = e;
	    return;
	  }
  *f = e;
  return;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-21  1:24 RFA: rtl-optimization/16643: cleanup_cfg() & register liveness Richard Sandiford
@ 2004-07-21  1:46 ` Richard Sandiford
  2004-07-21 17:27 ` Richard Sandiford
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Sandiford @ 2004-07-21  1:46 UTC (permalink / raw)
  To: gcc-patches

Richard Sandiford <rsandifo@redhat.com> writes:
> Slightly different patches are needed for mainline and branch.
> The mainline versions have been bootstrapped & regression tested on
> i686-pc-linux-gnu.  I'm testing the 3.4 patches on mips*-linux-gnu
> targets now.

Just to clarify: I tested the patches independently, not together.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-21  1:24 RFA: rtl-optimization/16643: cleanup_cfg() & register liveness Richard Sandiford
  2004-07-21  1:46 ` Richard Sandiford
@ 2004-07-21 17:27 ` Richard Sandiford
  2004-07-24 18:05   ` Richard Henderson
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Sandiford @ 2004-07-21 17:27 UTC (permalink / raw)
  To: gcc-patches

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

Richard Sandiford <rsandifo@redhat.com> writes:
> Slightly different patches are needed for mainline and branch.
> The mainline versions have been bootstrapped & regression tested on
> i686-pc-linux-gnu.  I'm testing the 3.4 patches on mips*-linux-gnu
> targets now.

FWIW, the mips tests completed OK.  As before, I tested the patches
separately, one on mips64-linux-gnu, the other on mips64el-linux-gnu.

Also realised that I forgot to document the new function parameters.
Doh!  Shame on me!  More properly commented versions are attached.

Richard


[-- Attachment #2: 16643-2-mainline.diff --]
[-- Type: text/plain, Size: 8891 bytes --]

	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
	(partition_hot_cold_basic_blocks): Pass 0 to cfg_layout_initialize.
	* function.c (thread_prologue_and_epilogue_insns): Likewise.
	* rtl.h (tracer): Add a flags parameter.
	* tracer.c (tracer): Pass it to cfg_layout_initialise.
	* passes.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
	(rest_of_handle_reorder_blocks): Update calls to tracer and
	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
	(rest_of_handle_tracer): Pass 0 to tracer.
	(rest_of_handle_loop2): Pass 0 to cfg_layout_initialize.

Index: cfglayout.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.h,v
retrieving revision 1.14
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.14 cfglayout.h
--- cfglayout.h	3 Jun 2004 15:01:08 -0000	1.14
+++ cfglayout.h	21 Jul 2004 07:26:53 -0000
@@ -25,7 +25,7 @@ #define GCC_CFGLAYOUT_H
 
 extern rtx cfg_layout_function_footer;
 
-extern void cfg_layout_initialize (void);
+extern void cfg_layout_initialize (unsigned int);
 extern void cfg_layout_finalize (void);
 extern void insn_locators_initialize (void);
 extern void reemit_insn_block_notes (void);
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.66
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.66 cfglayout.c
--- cfglayout.c	9 Jul 2004 03:29:26 -0000	1.66
+++ cfglayout.c	21 Jul 2004 07:26:54 -0000
@@ -1133,11 +1133,15 @@ cfg_layout_duplicate_bb (basic_block bb)
   return new_bb;
 }
 \f
-/* Main entry point to this module - initialize the data structures for
-   CFG layout changes.  It keeps LOOPS up-to-date if not null.  */
+/* Main entry point to this module - initialize the datastructures for
+   CFG layout changes.  It keeps LOOPS up-to-date if not null.
+
+   FLAGS is a set of additional flags to pass to cleanup_cfg().  It should
+   include CLEANUP_UPDATE_LIFE if liveness information must be kept up
+   to date.  */
 
 void
-cfg_layout_initialize (void)
+cfg_layout_initialize (unsigned int flags)
 {
   basic_block bb;
 
@@ -1152,7 +1156,7 @@ cfg_layout_initialize (void)
 
   record_effective_endpoints ();
 
-  cleanup_cfg (CLEANUP_CFGLAYOUT);
+  cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
 
 /* Splits superblocks.  */
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.201
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.201 basic-block.h
--- basic-block.h	16 Jul 2004 22:28:27 -0000	1.201
+++ basic-block.h	21 Jul 2004 07:26:54 -0000
@@ -677,7 +677,7 @@ extern bool inside_basic_block_p (rtx);
 extern bool control_flow_insn_p (rtx);
 
 /* In bb-reorder.c */
-extern void reorder_basic_blocks (void);
+extern void reorder_basic_blocks (unsigned int);
 extern void partition_hot_cold_basic_blocks (void);
 
 /* In cfg.c */
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.76
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.76 bb-reorder.c
--- bb-reorder.c	9 Jul 2004 03:29:25 -0000	1.76
+++ bb-reorder.c	21 Jul 2004 07:26:56 -0000
@@ -1908,10 +1908,11 @@ fix_edges_for_rarely_executed_code (edge
   add_reg_crossing_jump_notes ();
 }
 
-/* Reorder basic blocks.  The main entry point to this file.  */
+/* Reorder basic blocks.  The main entry point to this file.  FLAGS is
+   the set of flags to pass to cfg_layout_initialize().  */
 
 void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
 {
   int n_traces;
   int i;
@@ -1925,7 +1926,7 @@ reorder_basic_blocks (void)
 
   timevar_push (TV_REORDER_BLOCKS);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
 
   set_edge_can_fallthru_flag ();
   mark_dfs_back_edges ();
@@ -1999,7 +2000,7 @@ partition_hot_cold_basic_blocks (void)
   
   crossing_edges = xcalloc (max_edges, sizeof (edge));
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
   
   FOR_EACH_BB (cur_bb)
     if (cur_bb->index >= 0
Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.558
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.558 function.c
--- function.c	16 Jul 2004 20:34:12 -0000	1.558
+++ function.c	21 Jul 2004 07:27:02 -0000
@@ -5257,7 +5257,7 @@ thread_prologue_and_epilogue_insns (rtx 
          use return.  Inserting a jump 'by hand' is extremely messy, so
 	 we take advantage of cfg_layout_finalize using
 	fixup_fallthru_exit_predecessor.  */
-      cfg_layout_initialize ();
+      cfg_layout_initialize (0);
       FOR_EACH_BB (cur_bb)
 	if (cur_bb->index >= 0 && cur_bb->next_bb->index >= 0)
 	  cur_bb->rbi->next = cur_bb->next_bb;
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.491
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.491 rtl.h
--- rtl.h	17 Jul 2004 00:31:07 -0000	1.491
+++ rtl.h	21 Jul 2004 07:27:05 -0000
@@ -2440,7 +2440,7 @@ extern void if_convert (int);
 extern void invert_br_probabilities (rtx);
 extern bool expensive_function_p (int);
 /* In tracer.c */
-extern void tracer (void);
+extern void tracer (unsigned int);
 
 /* In var-tracking.c */
 extern void variable_tracking_main (void);
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.19
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.19 tracer.c
--- tracer.c	13 May 2004 06:39:45 -0000	1.19
+++ tracer.c	21 Jul 2004 07:27:06 -0000
@@ -354,17 +354,18 @@ layout_superblocks (void)
     }
 }
 
-/* Main entry point to this file.  */
+/* Main entry point to this file.  FLAGS is the set of flags to pass
+   to cfg_layout_initialize().  */
 
 void
-tracer (void)
+tracer (unsigned int flags)
 {
   if (n_basic_blocks <= 1)
     return;
 
   timevar_push (TV_TRACER);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
   mark_dfs_back_edges ();
   if (dump_file)
     dump_flow_info (dump_file);
Index: passes.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/passes.c,v
retrieving revision 2.32
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.32 passes.c
--- passes.c	17 Jul 2004 18:08:10 -0000	2.32
+++ passes.c	21 Jul 2004 07:27:07 -0000
@@ -549,7 +549,7 @@ rest_of_handle_stack_regs (void)
 		       | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
 	  && (flag_reorder_blocks || flag_reorder_blocks_and_partition))
 	{
-	  reorder_basic_blocks ();
+	  reorder_basic_blocks (0);
 	  cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
 	}
     }
@@ -734,23 +734,22 @@ static void
 rest_of_handle_reorder_blocks (void)
 {
   bool changed;
+  unsigned int liveness_flags;
+
   open_dump_file (DFI_bbro, current_function_decl);
 
   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
      splitting possibly introduced more crossjumping opportunities.  */
-  changed = cleanup_cfg (CLEANUP_EXPENSIVE
-			 | (!HAVE_conditional_execution
-			    ? CLEANUP_UPDATE_LIFE : 0));
+  liveness_flags = (!HAVE_conditional_execution ? CLEANUP_UPDATE_LIFE : 0);
+  changed = cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
-    tracer ();
+    tracer (liveness_flags);
   if (flag_reorder_blocks || flag_reorder_blocks_and_partition)
-    reorder_basic_blocks ();
+    reorder_basic_blocks (liveness_flags);
   if (flag_reorder_blocks || flag_reorder_blocks_and_partition
       || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
-    changed |= cleanup_cfg (CLEANUP_EXPENSIVE
-			    | (!HAVE_conditional_execution
-			       ? CLEANUP_UPDATE_LIFE : 0));
+    changed |= cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   /* On conditional execution targets we can not update the life cheaply, so
      we deffer the updating to after both cleanups.  This may lose some cases
@@ -897,7 +896,7 @@ rest_of_handle_tracer (void)
   open_dump_file (DFI_tracer, current_function_decl);
   if (dump_file)
     dump_flow_info (dump_file);
-  tracer ();
+  tracer (0);
   cleanup_cfg (CLEANUP_EXPENSIVE);
   reg_scan (get_insns (), max_reg_num (), 0);
   close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
@@ -1353,7 +1352,7 @@ rest_of_handle_loop2 (void)
     dump_flow_info (dump_file);
 
   /* Initialize structures for layout changes.  */
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
 
   loops = loop_optimizer_init (dump_file);
 

[-- Attachment #3: 16643-2-branch.diff --]
[-- Type: text/plain, Size: 7922 bytes --]

	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
	* loop-init.c (loop_optimizer_init): Pass 0 to cfg_layout_initialize.
	* rtl.h (tracer): Add a flags parameter.
	* tracer.c (tracer): Pass it to cfg_layout_initialise.
	* toplev.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
	(rest_of_handle_reorder_blocks): Update calls to tracer and
	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
	(rest_of_handle_tracer): Pass 0 to tracer.

Index: cfglayout.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.h,v
retrieving revision 1.10
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.10 cfglayout.h
--- cfglayout.h	30 Dec 2003 10:40:51 -0000	1.10
+++ cfglayout.h	21 Jul 2004 07:25:29 -0000
@@ -35,7 +35,7 @@ typedef struct reorder_block_def
 
 extern rtx cfg_layout_function_footer;
 
-extern void cfg_layout_initialize (void);
+extern void cfg_layout_initialize (unsigned int);
 extern void cfg_layout_finalize (void);
 extern bool cfg_layout_can_duplicate_bb_p (basic_block);
 extern basic_block cfg_layout_duplicate_bb (basic_block, edge);
Index: cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.50
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.50 cfglayout.c
--- cfglayout.c	30 Dec 2003 10:40:50 -0000	1.50
+++ cfglayout.c	21 Jul 2004 07:25:30 -0000
@@ -1118,10 +1118,14 @@ cfg_layout_initialize_rbi (basic_block b
 }
 \f
 /* Main entry point to this module - initialize the datastructures for
-   CFG layout changes.  It keeps LOOPS up-to-date if not null.  */
+   CFG layout changes.  It keeps LOOPS up-to-date if not null.
+
+   FLAGS is a set of additional flags to pass to cleanup_cfg().  It should
+   include CLEANUP_UPDATE_LIFE if liveness information must be kept up
+   to date.  */
 
 void
-cfg_layout_initialize (void)
+cfg_layout_initialize (unsigned int flags)
 {
   basic_block bb;
 
@@ -1137,7 +1141,7 @@ cfg_layout_initialize (void)
 
   record_effective_endpoints ();
 
-  cleanup_cfg (CLEANUP_CFGLAYOUT);
+  cleanup_cfg (CLEANUP_CFGLAYOUT | flags);
 }
 
 /* Splits superblocks.  */
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.186.4.3
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.186.4.3 basic-block.h
--- basic-block.h	30 Jan 2004 11:07:49 -0000	1.186.4.3
+++ basic-block.h	21 Jul 2004 07:25:31 -0000
@@ -606,7 +606,7 @@ extern bool inside_basic_block_p (rtx);
 extern bool control_flow_insn_p (rtx);
 
 /* In bb-reorder.c */
-extern void reorder_basic_blocks (void);
+extern void reorder_basic_blocks (unsigned int);
 
 /* In dominance.c */
 
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.63
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.63 bb-reorder.c
--- bb-reorder.c	20 Dec 2003 16:31:12 -0000	1.63
+++ bb-reorder.c	21 Jul 2004 07:25:32 -0000
@@ -1063,10 +1063,11 @@ get_uncond_jump_length (void)
   return length;
 }
 
-/* Reorder basic blocks.  The main entry point to this file.  */
+/* Reorder basic blocks.  The main entry point to this file.  FLAGS is
+   the set of flags to pass to cfg_layout_initialize().  */
 
 void
-reorder_basic_blocks (void)
+reorder_basic_blocks (unsigned int flags)
 {
   int n_traces;
   int i;
@@ -1080,7 +1081,7 @@ reorder_basic_blocks (void)
 
   timevar_push (TV_REORDER_BLOCKS);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
 
   set_edge_can_fallthru_flag ();
   mark_dfs_back_edges ();
Index: loop-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-init.c,v
retrieving revision 1.7.4.1
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.7.4.1 loop-init.c
--- loop-init.c	2 Mar 2004 01:12:04 -0000	1.7.4.1
+++ loop-init.c	21 Jul 2004 07:25:32 -0000
@@ -39,7 +39,7 @@ loop_optimizer_init (FILE *dumpfile)
   edge e;
 
   /* Initialize structures for layout changes.  */
-  cfg_layout_initialize ();
+  cfg_layout_initialize (0);
 
   /* Avoid annoying special cases of edges going to exit
      block.  */
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.448.4.5
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.448.4.5 rtl.h
--- rtl.h	21 Apr 2004 19:52:37 -0000	1.448.4.5
+++ rtl.h	21 Jul 2004 07:25:35 -0000
@@ -2334,6 +2334,6 @@ extern void if_convert (int);
 extern void invert_br_probabilities (rtx);
 extern bool expensive_function_p (int);
 /* In tracer.c */
-extern void tracer (void);
+extern void tracer (unsigned int);
 
 #endif /* ! GCC_RTL_H */
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.16
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.16 tracer.c
--- tracer.c	18 Dec 2003 17:07:24 -0000	1.16
+++ tracer.c	21 Jul 2004 07:25:35 -0000
@@ -354,17 +354,18 @@ layout_superblocks (void)
     }
 }
 
-/* Main entry point to this file.  */
+/* Main entry point to this file.  FLAGS is the set of flags to pass
+   to cfg_layout_initialize().  */
 
 void
-tracer (void)
+tracer (unsigned int flags)
 {
   if (n_basic_blocks <= 1)
     return;
 
   timevar_push (TV_TRACER);
 
-  cfg_layout_initialize ();
+  cfg_layout_initialize (flags);
   mark_dfs_back_edges ();
   if (rtl_dump_file)
     dump_flow_info (rtl_dump_file);
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.863.4.10
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.863.4.10 toplev.c
--- toplev.c	20 Feb 2004 08:40:49 -0000	1.863.4.10
+++ toplev.c	21 Jul 2004 07:25:39 -0000
@@ -2145,7 +2145,7 @@ rest_of_handle_stack_regs (tree decl, rt
 		       | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
 	  && flag_reorder_blocks)
 	{
-	  reorder_basic_blocks ();
+	  reorder_basic_blocks (0);
 	  cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK);
 	}
     }
@@ -2317,23 +2317,22 @@ static void
 rest_of_handle_reorder_blocks (tree decl, rtx insns)
 {
   bool changed;
+  unsigned int liveness_flags;
+
   open_dump_file (DFI_bbro, decl);
 
   /* Last attempt to optimize CFG, as scheduling, peepholing and insn
      splitting possibly introduced more crossjumping opportunities.  */
-  changed = cleanup_cfg (CLEANUP_EXPENSIVE
-			 | (!HAVE_conditional_execution
-			    ? CLEANUP_UPDATE_LIFE : 0));
+  liveness_flags = (!HAVE_conditional_execution ? CLEANUP_UPDATE_LIFE : 0);
+  changed = cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
-    tracer ();
+    tracer (liveness_flags);
   if (flag_reorder_blocks)
-    reorder_basic_blocks ();
+    reorder_basic_blocks (liveness_flags);
   if (flag_reorder_blocks
       || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
-    changed |= cleanup_cfg (CLEANUP_EXPENSIVE
-			    | (!HAVE_conditional_execution
-			       ? CLEANUP_UPDATE_LIFE : 0));
+    changed |= cleanup_cfg (CLEANUP_EXPENSIVE | liveness_flags);
 
   /* On conditional execution targets we can not update the life cheaply, so
      we deffer the updating to after both cleanups.  This may lose some cases
@@ -2423,7 +2422,7 @@ rest_of_handle_tracer (tree decl, rtx in
   open_dump_file (DFI_tracer, decl);
   if (rtl_dump_file)
     dump_flow_info (rtl_dump_file);
-  tracer ();
+  tracer (0);
   cleanup_cfg (CLEANUP_EXPENSIVE);
   reg_scan (insns, max_reg_num (), 0);
   close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-21 17:27 ` Richard Sandiford
@ 2004-07-24 18:05   ` Richard Henderson
  2004-07-25  2:19     ` Richard Sandiford
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2004-07-24 18:05 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

On Wed, Jul 21, 2004 at 08:32:03AM +0100, Richard Sandiford wrote:
> 	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
> 	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
> 	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
> 	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
> 	(partition_hot_cold_basic_blocks): Pass 0 to cfg_layout_initialize.
> 	* function.c (thread_prologue_and_epilogue_insns): Likewise.
> 	* rtl.h (tracer): Add a flags parameter.
> 	* tracer.c (tracer): Pass it to cfg_layout_initialise.
> 	* passes.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
> 	(rest_of_handle_reorder_blocks): Update calls to tracer and
> 	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
> 	(rest_of_handle_tracer): Pass 0 to tracer.
> 	(rest_of_handle_loop2): Pass 0 to cfg_layout_initialize.

Ok.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-24 18:05   ` Richard Henderson
@ 2004-07-25  2:19     ` Richard Sandiford
  2004-07-25 11:39       ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Sandiford @ 2004-07-25  2:19 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

Richard Henderson <rth@redhat.com> writes:
> On Wed, Jul 21, 2004 at 08:32:03AM +0100, Richard Sandiford wrote:
>> 	* cfglayout.h (cfg_layout_initialize): Add a flags parameter.
>> 	* cfglayout.c (cfg_layout_initialize): Pass it to cleanup_cfg.
>> 	* basic-block.h (reorder_basic_blocks): Add a flags parameter.
>> 	* cfglayout.c (reorder_basic_blocks): Pass it to cfg_layout_initialize.
>> 	(partition_hot_cold_basic_blocks): Pass 0 to cfg_layout_initialize.
>> 	* function.c (thread_prologue_and_epilogue_insns): Likewise.
>> 	* rtl.h (tracer): Add a flags parameter.
>> 	* tracer.c (tracer): Pass it to cfg_layout_initialise.
>> 	* passes.c (rest_of_handle_stack_regs): Pass 0 to reorder_basic_blocks.
>> 	(rest_of_handle_reorder_blocks): Update calls to tracer and
>> 	reorder_basic_blocks, passing CLEANUP_UPDATE_LIFE if appropriate.
>> 	(rest_of_handle_tracer): Pass 0 to tracer.
>> 	(rest_of_handle_loop2): Pass 0 to cfg_layout_initialize.
>
> Ok.

Thanks.  For branch as well as mainline?

Is the other patch in the same message OK too?  The one that calls
update_forward_flag() after simplifying a jump?

Richard

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-25  2:19     ` Richard Sandiford
@ 2004-07-25 11:39       ` Richard Henderson
  2004-07-26 22:27         ` Richard Sandiford
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2004-07-25 11:39 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

On Sat, Jul 24, 2004 at 07:18:14AM +0100, Richard Sandiford wrote:
> Thanks.  For branch as well as mainline?

Yes.

> Is the other patch in the same message OK too?  The one that calls
> update_forward_flag() after simplifying a jump?

Oh, I thought that was the same patch for the branch.
And now I've deleted it.  Can you re-send?


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-25 11:39       ` Richard Henderson
@ 2004-07-26 22:27         ` Richard Sandiford
  2004-07-26 22:57           ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Sandiford @ 2004-07-26 22:27 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

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

Richard Henderson <rth@redhat.com> writes:
>> Is the other patch in the same message OK too?  The one that calls
>> update_forward_flag() after simplifying a jump?
>
> Oh, I thought that was the same patch for the branch.
> And now I've deleted it.  Can you re-send?

Sure, attached.  Original explanation was here:

    http://gcc.gnu.org/ml/gcc-patches/2004-07/msg01956.html

Richard


	* cfgcleanup.c (try_simplify_condjump): Call update_forwarder_flag
	after simplifying the jump.


[-- Attachment #2: 16643-v1-branch.diff --]
[-- Type: text/plain, Size: 631 bytes --]

Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.99.2.5
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.99.2.5 cfgcleanup.c
--- cfgcleanup.c	6 Mar 2004 01:24:08 -0000	1.99.2.5
+++ cfgcleanup.c	20 Jul 2004 13:46:43 -0000
@@ -196,6 +196,7 @@ try_simplify_condjump (basic_block cbran
   /* Delete the block with the unconditional jump, and clean up the mess.  */
   delete_block (jump_block);
   tidy_fallthru_edge (cbranch_jump_edge, cbranch_block, cbranch_dest_block);
+  update_forwarder_flag (cbranch_block);
 
   return true;
 }

[-- Attachment #3: 16643-v1-mainline.diff --]
[-- Type: text/plain, Size: 594 bytes --]

Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.121
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.121 cfgcleanup.c
--- cfgcleanup.c	17 Jul 2004 00:31:05 -0000	1.121
+++ cfgcleanup.c	20 Jul 2004 13:24:23 -0000
@@ -187,6 +187,7 @@ try_simplify_condjump (basic_block cbran
   /* Delete the block with the unconditional jump, and clean up the mess.  */
   delete_basic_block (jump_block);
   tidy_fallthru_edge (cbranch_jump_edge);
+  update_forwarder_flag (cbranch_block);
 
   return true;
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: RFA: rtl-optimization/16643: cleanup_cfg() & register liveness
  2004-07-26 22:27         ` Richard Sandiford
@ 2004-07-26 22:57           ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2004-07-26 22:57 UTC (permalink / raw)
  To: Richard Sandiford; +Cc: gcc-patches

On Mon, Jul 26, 2004 at 03:48:40PM +0100, Richard Sandiford wrote:
> 	* cfgcleanup.c (try_simplify_condjump): Call update_forwarder_flag
> 	after simplifying the jump.

Ok.


r~

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-07-26 18:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-21  1:24 RFA: rtl-optimization/16643: cleanup_cfg() & register liveness Richard Sandiford
2004-07-21  1:46 ` Richard Sandiford
2004-07-21 17:27 ` Richard Sandiford
2004-07-24 18:05   ` Richard Henderson
2004-07-25  2:19     ` Richard Sandiford
2004-07-25 11:39       ` Richard Henderson
2004-07-26 22:27         ` Richard Sandiford
2004-07-26 22:57           ` Richard Henderson

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