This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Off-by-one error in ARM's thumb_jump pattern
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Richard Earnshaw <rearnsha at arm dot com>
- Date: Tue, 30 Mar 2004 10:36:43 +0100
- Subject: Re: Off-by-one error in ARM's thumb_jump pattern
- Organization: ARM Ltd.
- Reply-to: Richard Earnshaw <rearnsha at arm dot com>
> 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.