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

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

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 

# 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

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

More information about the fpc-devel mailing list