[fpc-devel] Double-checking an optimisation

Florian Klämpfl florian at freepascal.org
Sun Jan 9 15:33:22 CET 2022

> Am 09.01.2022 um 15:08 schrieb J. Gareth Moreton via fpc-devel <fpc-devel at lists.freepascal.org>:
> On 09/01/2022 12:35, Florian Klämpfl via fpc-devel wrote:
>>>   It removes a jump and a label, which might permit other long-range optimisations, but it's 3 instructions that are in a dependency chain.
>> Didn't you implement something which transformed the code above in
>>       xorl    %ebx,%ebx
>>       cmpl    $1,%ecx
>>       setg    %bl
>>       subl    %ebx,%ecx
>> ?
> I believe I did, yes.  I'll have to double-check if the "jcc -> setcc" optimisation is actually mine or if I just adapted it to use GetIntRegisterBetween.  That's certainly the better sequence because XOR is a smaller instruction (2 bytes, I believe) and it breaks the dependency chain, since it can execute at the same time as the CMP instruction.
> Either way, it's not being performed here, so that's another optimisation to add to my ever-growing list!  Yes, I've got a new optimisation ready to merge request soon - I'm running my local tests as we speak.  I need to discipline myself a bit and try to fix the bug on 3.2.4's i386-linux implementation.

Yes, this is always why I am behind with the merge request, we have to finish 3.2.4.

More information about the fpc-devel mailing list