This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: reorg branch displacement fix
- From: tm <tm at mail dot kloo dot net>
- To: law at redhat dot com
- Cc: kkojima at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 1 Nov 2002 14:48:38 -0800 (PST)
- Subject: Re: PATCH: reorg branch displacement fix
On Fri, 1 Nov 2002, Jeff Law wrote:
> In message <Pine.LNX.4.21.0210311508160.3016-100000@mail.kloo.net>, tm writes:
> >
> >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.
> This is wrong. reorg does not and should not be checking branch displacements.
> That is a problem for shorten-branches and the backend.
>
Okay, here's a revised patch:
2002-10-31 Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
* reorg.c (relax_delay_slots): Don't thread conditional branches.
*** reorg.c.bak Thu Oct 31 13:38:29 2002
--- reorg.c Fri Nov 1 13:13:20 2002
*************** relax_delay_slots (first)
*** 3277,3300 ****
if (target_label)
{
! /* If this jump goes to another unconditional jump, thread it, but
! don't convert a jump into a RETURN here. */
! trial = follow_jumps (target_label);
! /* We use next_real_insn instead of next_active_insn, so that
! the special USE insns emitted by reorg won't be ignored.
! If they are ignored, then they will get deleted if target_label
! is now unreachable, and that would cause mark_target_live_regs
! to fail. */
! trial = prev_label (next_real_insn (trial));
! if (trial == 0 && target_label != 0)
! 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;
! }
/* If the first insn at TARGET_LABEL is redundant with a previous
insn, redirect the jump to the following insn process again. */
--- 3277,3285 ----
if (target_label)
{
! /* Code previously here to thread unconditional jumps was deleted
! because it caused problems and this should be handled by
! shorten_branches and/or machine_dependent_reorg anyway. */
/* If the first insn at TARGET_LABEL is redundant with a previous
insn, redirect the jump to the following insn process again. */