This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Long and short jumps
- From: Mike Stump <mrs at apple dot com>
- To: Nathan Sidwell <nathan at codesourcery dot com>
- Cc: gcc <gcc at gcc dot gnu dot org>
- Date: Fri, 21 May 2004 16:04:18 -0700
- Subject: Re: Long and short jumps
On Friday, May 21, 2004, at 10:50 AM, Nathan Sidwell wrote:
I have this architecture which has limited range short jumps.
Everybody does...
Long range jumps require a register
Yup.
Then have a machine dependent reorg pass that fixes the long
conditional jumps to be short conditional jumps to unconditional long
jump stubs. If possible I'd like the opportunity before register
allocation to remove the link clobbers, if the function is small
enough that a short jump can always be used.
It would be nice to have this type of functionality generally available
in the compiler.
The recent work with hot/cold partitioning faces these same type of
problems, as do the various longcall bits. I think it'd be nice to
unify and expand the functionality and move more and more of it into
the mi parts of the compiler.
On our platform, we have a jmp instruction that takes two places to
jump, one clobbers a register and gets there even if it is far away,
and the other is just the destination. Later (as or ld time), when we
know how far the code will be away, we use the short form of the branch
instruction, if the distance is short enough, else we jump to the
branch island (that's the one that kills the register and does the 32
bit branch).
The advantage is that when the final code is small enough, the fast
instructions are used in places where we otherwise would have to
generate the slower instructions. We avoid the extra branch, the space
in the branch predictor, the fact that it is an indirect jump. We
don't recover the extra register.