[fpc-devel] fpc bug with M1
Jonas Maebe
jonas at freepascal.org
Thu Dec 30 21:18:15 CET 2021
On 30/12/2021 21:07, Jonas Maebe via fpc-devel wrote:
> On 30/12/2021 21:03, Florian Klämpfl via fpc-devel wrote:
>> Yes, but the question is: if we load a shortint into a register, do we
>> need to sign extend it to 32/64 bit or not? I tend more and more to
>> say that we shouldn’t require this.
>>
>> Neither clang nor gcc seem to expect this for arguments/return values:
>> https://godbolt.org/z/sv5fPP6GM
>
> This is not related to arguments/return values. We do the same on on
> PPC, and afaik on all architectures that don't have 8/16 bit
> subregisters. I initially did it on PPC because it simplified code
> generation a lot and solved all kinds of small issues I got otherwise
> because non-cleared higher parts of registers were used. Maybe with our
> current code generators it would work better.
Actually, the main reason may have been register variables: in the code
generator you don't know whether a register is a register variable or
not. So if you don't sign/zero extend values on initialising a register,
then you have to zero/sign extend them every time you read them. And
reading generally happens a lot more often than writing.
Jonas
More information about the fpc-devel
mailing list