public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: PATCH: reorg branch displacement fix
@ 2002-11-01 14:13 Joern Rennecke
  2002-11-01 14:49 ` Jeff Law
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Joern Rennecke @ 2002-11-01 14:13 UTC (permalink / raw)
  To: law; +Cc: tm, kkojima, gcc-patches

> > * 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.
> This is wrong.  reorg does not and should not be checking branch displacements.
> That is a problem for shorten-branches and the backend.

The SH does some early branch shortening in machine_dependent_reorg because
a long conditional branch has to be split into a short conditional branch
around an unconditional branch, or a short conditional branch to an unconditional
branch (that might have been inserted elsewhere after an inverted condbranch).
Unconditional branches have mandatory delay slots, so we get additional
delay slots exposed by doing this splitting before reorg, and the conditional
branches have optional delay slots, which obviously can't be used in the same
way when the branch is reversed or redirected.
Thus, machine_dependent_reorg already makes sure all the conditional branches
that need splitting are split.  If reorg redirects conditional branches
willy-nilly, it destroys the very data it is supposed to operate on.
	
-- 
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658

^ permalink raw reply	[flat|nested] 17+ messages in thread
* PATCH: reorg branch displacement fix
@ 2002-10-31 15:25 tm
  2002-11-01  6:34 ` Jeff Law
  0 siblings, 1 reply; 17+ messages in thread
From: tm @ 2002-10-31 15:25 UTC (permalink / raw)
  To: kkojima, law; +Cc: gcc-patches


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;
  	    }

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

end of thread, other threads:[~2002-11-06 20:18 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-01 14:13 PATCH: reorg branch displacement fix Joern Rennecke
2002-11-01 14:49 ` Jeff Law
2002-11-01 14:52   ` tm
2002-11-01 15:21   ` Joern Rennecke
2002-11-01 15:37     ` Jeff Law
2002-11-01 14:51 ` tm
2002-11-01 15:05   ` Jeff Law
2002-11-04 15:16     ` Joern Rennecke
2002-11-04 17:40       ` Hans-Peter Nilsson
2002-11-05 11:45 ` tm
2002-11-06 12:18   ` Joern Rennecke
  -- strict thread matches above, loose matches on Subject: below --
2002-10-31 15:25 tm
2002-11-01  6:34 ` Jeff Law
2002-11-01 11:35   ` tm
2002-11-03 12:34     ` Jeff Law
2002-11-01 14:55   ` tm
2002-11-01 15:07     ` Jeff Law

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