Patch to cleanup / improve jump_optimize_1 (version 2)

John Wehle john@feith.com
Tue Apr 10 12:17:00 GMT 2001


Currently jump_optimize_1 attempts to delete trivially dead insns
itself instead of relying on delete_trivially_dead_insns having
been run.  The patch passes make bootstrap and check on i386-pc-solaris2.7.
It also passes make and check on arm-elf and powerpc-eabisim.

Notes:

  1) JUMP_NOOP_MOVES is only set after reload and controls the call
     to delete_noop_moves which I've left in for the time being since
     it does some things not currently covered by delete_trivially_dead_insns.

  2) JUMP_AFTER_REGSCAN is only set twice.  On the initial call to
     jump_optimize and on the call prior to cse2.  It doesn't seem likely
     that trivially dead insns exist right after instantiating all the
     virtual registers so I only added the delete_trivially_dead_insns
     call prior to cse2.

ChangeLog:

Mon Apr  9 23:41:20 EDT 2001  John Wehle  (john@feith.com)

	* jump.c (jump_optimize_1): Don't delete dead stores here.
	* toplev.c (rest_of_compilation): Call delete_trivially_dead_insns
	prior to running jump optimize before cse2.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/jump.c.ORIGINAL	Sat Apr  7 00:37:24 2001
--- gcc/jump.c	Mon Apr  9 23:19:46 2001
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 248,282 ****
    if (noop_moves)
      delete_noop_moves (f);
  
-   /* If we haven't yet gotten to reload and we have just run regscan,
-      delete any insn that sets a register that isn't used elsewhere.
-      This helps some of the optimizations below by having less insns
-      being jumped around.  */
- 
-   if (optimize && ! reload_completed && after_regscan)
-     for (insn = f; insn; insn = next)
-       {
- 	rtx set = single_set (insn);
- 
- 	next = NEXT_INSN (insn);
- 
- 	if (set && GET_CODE (SET_DEST (set)) == REG
- 	    && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER
- 	    && REGNO_FIRST_UID (REGNO (SET_DEST (set))) == INSN_UID (insn)
- 	    /* We use regno_last_note_uid so as not to delete the setting
- 	       of a reg that's used in notes.  A subsequent optimization
- 	       might arrange to use that reg for real.  */
- 	    && REGNO_LAST_NOTE_UID (REGNO (SET_DEST (set))) == INSN_UID (insn)
- 	    && ! side_effects_p (SET_SRC (set))
- 	    && ! find_reg_note (insn, REG_RETVAL, 0)
- 	    /* An ADDRESSOF expression can turn into a use of the internal arg
- 	       pointer, so do not delete the initialization of the internal
- 	       arg pointer yet.  If it is truly dead, flow will delete the
- 	       initializing insn.  */
- 	    && SET_DEST (set) != current_function_internal_arg_pointer)
- 	  delete_insn (insn);
-       }
- 
    /* Now iterate optimizing jumps until nothing changes over one pass.  */
    changed = 1;
    old_max_reg = max_reg_num ();
--- 248,253 ----
*** gcc/toplev.c.ORIGINAL	Wed Apr  4 00:23:15 2001
--- gcc/toplev.c	Mon Apr  9 23:15:06 2001
*************** rest_of_compilation (decl)
*** 3208,3213 ****
--- 3208,3219 ----
  	     ??? Rework to not call reg_scan so often.  */
  	  timevar_push (TV_JUMP);
  
+ 	  /* The previous call to loop_optimize makes some instructions
+ 	     trivially dead.  We delete those instructions now in the
+ 	     hope that doing so will make the heuristics in jump work
+ 	     better and possibly speed up compilation.  */
+ 	  delete_trivially_dead_insns (insns, max_reg_num ());
+ 
  	  reg_scan (insns, max_reg_num (), 0);
  	  jump_optimize (insns, !JUMP_CROSS_JUMP,
  			 !JUMP_NOOP_MOVES, JUMP_AFTER_REGSCAN);
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



More information about the Gcc-patches mailing list