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]

Remove trivially dead instructions after try_optimize_cfg



Hi,
this patch makes try_optimize_cfg to cleanup trivially dead instructions
after some jumps has been converted to unconditional ones.

Bootstrapped/regtested i586.

Honza

Fri Jun 29 14:46:23 CEST 2001  Jan Hubicka  <jh@suse.cz>
	* flow.c (jump_converted): New static variable.
	(try_redirect_by_replacing_jump): set.
	(try_optimize_cfg): Clear; call delete_trivially_dead_insns
	if true.
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.410
diff -c -3 -p -r1.410 flow.c
*** flow.c	2001/06/29 03:30:17	1.410
--- flow.c	2001/06/29 12:44:48
*************** struct depth_first_search_dsS {
*** 355,360 ****
--- 355,362 ----
  };
  typedef struct depth_first_search_dsS *depth_first_search_ds;
  
+ static int jump_converted;
+ 
  /* Have print_rtl_and_abort give the same information that fancy_abort
     does.  */
  #define print_rtl_and_abort() \
*************** try_redirect_by_replacing_jump (e, targe
*** 1662,1667 ****
--- 1666,1672 ----
        if (rtl_dump_file)
  	fprintf (rtl_dump_file, "Removing jump %i.\n", INSN_UID (insn));
        flow_delete_insn (insn);
+       jump_converted = 1;
        fallthru = 1;
        insn = src->end;
      }
*************** try_redirect_by_replacing_jump (e, targe
*** 1688,1693 ****
--- 1693,1699 ----
  	fprintf (rtl_dump_file, "Replacing insn %i by jump %i\n",
  		 INSN_UID (insn), INSN_UID (src->end));
        flow_delete_insn (insn);
+       jump_converted = 1;
        insn = src->end;
      }
  
*************** try_optimize_cfg ()
*** 2966,2971 ****
--- 3043,3049 ----
    do
      {
        changed = 0;
+       jump_converted = 0;
        for (i = 0; i < n_basic_blocks;)
  	{
  	  basic_block c, b = BASIC_BLOCK (i);
*************** try_optimize_cfg ()
*** 3037,3042 ****
--- 3121,3133 ----
  	  else
  	    changed = 1;
  	}
+       /* In case we've converted an jump instruction, remove insns used to
+          compute condition or address.  */
+       if (jump_converted)
+ 	{
+ 	  delete_trivially_dead_insns (get_insns (), max_reg_num (), 1);
+ 	  set_basic_block_flags ();
+ 	}
        changed_overall |= changed;
        changed = 0;
      }


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