PATCH: reorg branch displacement fix

Jeff Law law@porcupine.cygnus.com
Sun Nov 3 12:34:00 GMT 2002


In message <Pine.LNX.4.21.0211011127060.4789-100000@mail.kloo.net>, tm writes:
 >On Fri, 1 Nov 2002, Jeff Law wrote:
 >
 >> In message <Pine.LNX.4.21.0210311508160.3016-100000@mail.kloo.net>, tm writ
 >es:
 >>  >
 >>  >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 displaceme
 >nts.
 >> That is a problem for shorten-branches and the backend.
 >> 
 >> jeff
 >
 >Aha! I see now. I will try disabling that chunk of code, and testing.
 >
 >Incidentially, MD_CAN_REDIRECT_BRANCH is already used in reorg in one
 >other place, in steal_delay_list_from_target():
 >
 >#ifdef MD_CAN_REDIRECT_BRANCH
 >  /* On some targets, branches with delay slots can have a limited
 >     displacement.  Give the back end a chance to tell us we can't do
 >     this.  */
 >  if (! MD_CAN_REDIRECT_BRANCH (insn, XVECEXP (seq, 0, 0)))
 >    return delay_list;
 >#endif
 >
 >This should probably be fixed as well.
Yup.  That code never should have gone into reorg.  It't counter to one of
the fundamental design decisions we made when creating the reorg pass.

jeff



More information about the Gcc-patches mailing list