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]

Patch to improve jump_optimize_1


Currently jump_optimize_1 doesn't handle cond_exec or constant calls
when deleting unused sets.  The patch passes make bootstrap and check
on i386-unknown-freebsd4.2.  It also passes make and check on
arm-elf and powerpc-eabisim.

Notes:

  1) This patch requires the single_set_2 simple set patch.

ChangeLog:

Sun Apr  8 01:50:11 EDT 2001  John Wehle  (john@feith.com)

	* jump.c (jump_optimize_1): When deleting unused sets
	handle cond_exec, constant calls have no side effects,
	and use delete_computation.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/jump.c.ORIGINAL	Sat Apr  7 00:37:24 2001
--- gcc/jump.c	Sun Apr  8 01:36:55 2001
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 256,265 ****
    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)
--- 256,276 ----
    if (optimize && ! reload_completed && after_regscan)
      for (insn = f; insn; insn = next)
        {
! 	rtx pat;
! 	rtx set;
  
  	next = NEXT_INSN (insn);
  
+ 	if (! INSN_P (insn))
+ 	  continue;
+ 
+ 	pat = PATTERN (insn);
+ 
+ 	if (GET_CODE (pat) == COND_EXEC)
+ 	  pat = COND_EXEC_CODE (pat);
+ 
+ 	set = single_set_2 (insn, pat);
+ 
  	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)
*************** jump_optimize_1 (f, cross_jump, noop_mov
*** 267,280 ****
  	       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.  */
--- 278,292 ----
  	       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)
! 	    && ((GET_CODE (insn) == CALL_INSN && CONST_CALL_P (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_computation (insn);
        }
  
    /* Now iterate optimizing jumps until nothing changes over one pass.  */
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


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