[PATCH] Optimize long branch for MIPS64 by removing calculation of %higher and %highest

Mark Seaborn mseaborn at chromium.org
Wed May 21 13:42:29 PDT 2014


On 15 May 2014 09:42, Sasa Stankovic <Sasa.Stankovic at imgtec.com> wrote:

> > I was wondering whether tail calls to other functions would become jumps
> that would > need handling via MipsLongBranch. The answer seems to be that
> LLVM always
>  > compiles function calls to indirect jumps on MIPS. (However, GCC does
> compile tail > calls to direct jumps.) That answer seems a bit crazy, so
> I'm not sure if it's right. You> should check. Does the MIPS linker insert
> veneers to handle long direct jumps the
> > same way ARM linkers do?
>
> I checked tail calls on LLVM and GCC, and they generate similar code when
> given explicit relocation model on the command line. When relocation model
> is omitted the code differs because default for MIPS GCC is non-pic, and
> for MIPS LLVM is pic. For pic code (which this patch handles) tail calls
> are replaced by load from GOT and indirect jump:
>
> lw      $t9, %call16(func)($gp)
> jr      $t9
>
> and this doesn't need long branch.


OK.  And the non-PIC (-relocation-model=static) case is OK because it
generates "j" or "jal" (taking a 26-bit absolute address) for a function
call rather than "b" or "bal" (taking a 16-bit relative address, for which
expanding using MipsLongBranch was necessary).  Looks like function calls
aren't affected by this change, then.  LGTM still.

Cheers,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140521/409e7cdf/attachment.html>


More information about the llvm-commits mailing list