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]
Other format: [Raw text]

PATCH: reorg branch displacement fix


This fixes the problem mentioned in:

http://gcc.gnu.org/ml/gcc-bugs/2002-06/msg00896.html

When a conditional branch jumps to an unconditional branch, reorg will
thread the branch without checking if the conditional branch has enough
displacement bits to branch to the target.

This patch uses MD_CAN_REDIRECT_BRANCH (as suggested by Joern in followup
messages to original message) to implement the substitution checking.

Please review and if correct, commit as I don't have CVS access.

Toshi

Thu Oct 31  Toshiyasu Morita  <toshiyasu.morita@hsa.hitachi.com>

	* reorg.c (relax_delay_slots): Don't thread conditional jump
        through unconditional jump if the conditional jump can't reach
        the branch target on this processor target.

*** reorg.c	Thu Oct 31 13:38:29 2002
--- reorg.c.new	Thu Oct 31 13:37:24 2002
*************** relax_delay_slots (first)
*** 3290,3297 ****
  	    trial = find_end_label ();
  
  	  if (trial != target_label
! 	      && redirect_with_delay_slots_safe_p (delay_insn, trial, insn))
! 	    {
  	      reorg_redirect_jump (delay_insn, trial);
  	      target_label = trial;
  	    }
--- 3290,3304 ----
  	    trial = find_end_label ();
  
  	  if (trial != target_label
! 	      && redirect_with_delay_slots_safe_p (delay_insn, trial, insn)
! #ifdef MD_CAN_REDIRECT_BRANCH
!               /* Ensure the conditional branch has enough jump displacement
!                  to reach the target of the unconditional branch before
!                  we redirect the unconditional branch.  */
!               && MD_CAN_REDIRECT_BRANCH (delay_insn, next)
! #endif
!               )
! {
  	      reorg_redirect_jump (delay_insn, trial);
  	      target_label = trial;
  	    }


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