On Fri, 25 Feb 2022 05:08:48 +0000
"J. Gareth Moreton via fpc-devel" <fpc-devel@lists.freepascal.org> wrote:


> Almost every source file in the compiler and the RTL shows some kind of 
> improvement.  A lot of them are just redundant pointer deallocations, so 
> this will help with cache misses and the like - that aside though, here 
> are a couple of my favourites... one from dbgdwarf - 
> TDebugInfoDwarf.appendsym_fieldvar_with_name_offset:
> 
> Before:
> 
>      ...
> .Lj682:
>      leaq    (,%r13,8),%rcx
>      movq    120(%rdi),%rax
>      cqto
>      idivq    %rcx
>      imulq    %r13,%rax
>      movq    %rax,%r12
>      addq    56(%rbp),%r12
>      leaq    (,%r13,8),%rcx
>      movq    120(%rdi),%rax
>      cqto
>      idivq    %rcx
>      movq    %rdx,%rsi
>      cmpb    $0,U_$SYSTEMS_$$_TARGET_INFO+276(%rip)
> 
> After:
> 
>      ...
> .Lj682:
>      leaq    (,%r13,8),%rcx
>      movq    120(%rdi),%rax
>      cqto
>      idivq    %rcx
>      imulq    %r13,%rax
>      movq    %rax,%r12
>      addq    56(%rbp),%r12
>      movq    %rdx,%rsi
>      cmpb    $0,U_$SYSTEMS_$$_TARGET_INFO+276(%rip)
> 
> This one has successfully removed an IDIV instruction because the 
> algorithm was able to detect that the subroutine wanted the remainder in 
> %edx, and it was still available from the first IDIV call because it 
> hadn't been overwritten, and neither %r13 nor %rdi had changed values so 
> the references are the same.

This is very useful, thank you.
I think FPC has an excellent register allocator, but frustrated on 32 bit
by scarce resources and by the lack of reloading check.

-- 
Simplex sigillum veri
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to