[fpc-devel] Finally fixed that MOVZX/SX optimisation!

J. Gareth Moreton gareth at moreton-family.com
Thu Feb 20 21:50:10 CET 2020


Oh, sorry, I made a slight error.  The sequences only appear if you 
specify -Oonoconstprop (and -a).  So that sequence is produced with 
"\pp\bin\x86_64-win64\ppcx64 -O4 -Oonoconstprop -a test\cg\tcnvint3b.pp"

There are still some inefficient combinations though in the assembly - 
for example:

     movl    $61441,%eax
     movw    $61441,%ax

Gareth aka. Kit

On 20/02/2020 20:45, J. Gareth Moreton wrote:
> On 20/02/2020 20:34, Florian Klämpfl wrote:
>> Am 20.02.20 um 21:25 schrieb J. Gareth Moreton:
>>> but if you run all of the "test/cg/tcnvint3" tests with the "-a" 
>>> option, you will notice such sequences in some of the ".s" file.
>>
>> With full -O3?
>
> Indeed so, with full -O4 even.  When compiling "/test/cg/tcnvint3.pp" 
> (a test that already exists) with -O4, we get things like this in the 
> assembler dump - command line = "\pp\bin\x86_64-win64\ppcx64 -O4 
> test\cg\tcnvint3b.pp":
>
> # Peephole Optimization: movq $16711680,%rax -> movl $16711680,%eax 
> (immediate can be represented with just 32 bits)
>     movl    $16711680,%eax
>     cmpl    $16711680,%eax
>     je    .Lj29
>     call    P$TCNVINT3_$$_FAIL
>     jmp    .Lj30
>     .p2align 4,,10
>     .p2align 3
> .Lj29:
>
> In this case, unless there's a freak CPU error, everything between "je 
> .Lj29" and its destination label will never execute (if "je .Lj29" is 
> changed to "jmp .Lj29", everything between them will be stripped by 
> pass 1 of the peephole optimiser).
>
> Gareth aka. Kit
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>


More information about the fpc-devel mailing list