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]

Re: Off-by-one error in ARM's thumb_jump pattern


> Hi Guys,
> 
>   We recently uncovered an off-by-one error in the code in the
>   thumb_jump pattern to decide if a regular thumb branch instruction
>   can be used or if a long-jump has to be used.  The constants used to
>   check the range were slightly off, as demonstrated by the test
>   program attached.  (Remember to compile it with -mthumb).
> 
>   I am proposing applying the patch below to fix this bug, and also to
>   slightly extend the forward-branch range, since it was a little
>   paranoid and the test file shows that a few bytes will work.
> 
>   Does anyone have any objections ?  (I would also be adding the test
>   code to the gcc testsuite).
> 
> Cheers
>         Nick
> 
> gcc/ChangeLog        
> 2004-03-29  Nick Clifton  <nickc@redhat.com>
> 
> 	* config/arm/arm.md (thumb_jump): Reduce the backward branch
> 	range, and increase the forward branch range, to allow for
> 	the fact that the PC will be off by 4.

This is fine.  It's probably too late for 3.4.0 now, but should be 
propagated there in time for 3.4.1.

> 
> gcc/testsuite/ChangeLog        
> 2004-03-29  Nick Clifton  <nickc@redhat.com>
> 
> 	* gcc.c-torture/compile/thumb_jump.c: New file to exercise the
> 	thumb_jump pattern in arm.md.
> 
>   The coding is dubious.  It relies upon the behaviour of gcc at the time of
>   coding (2004-03-29) and will probably fail to produce the expected
>   distances between the branches in the future. 

I'm not so sure about this, however: fragile tests a just a pain.  In any 
case, this should probably be part of gcc.dg.

R.


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