[Lazarus] UTF8LengthFast returning incorrect results on AARCH64 (MacOS)

Juha Manninen juha.manninen62 at gmail.com
Tue Dec 28 13:09:33 CET 2021


On Tue, Dec 28, 2021 at 1:45 PM Bart via lazarus <
lazarus at lists.lazarus-ide.org> wrote:

> @Juha: can you please comment on my possible improvement using PopCnt
> instead of a multiplication with ONEMASK.
>

I confess I didn't remember what PopCnt does. I checked from the net.
FPC implements it as internproc.
  function PopCnt(Const AValue : QWord): QWord;[internproc:fpc_in_popcnt_x];
I guess it translates to one x86_64 instruction.
Is it implemented for all CPUs? I found this:
  https://gitlab.com/freepascal.org/fpc/source/-/issues/38729
If it works everywhere, good. It looks like another good optimization for
this highly optimized function.


I will patch the function using unsigned types where applicable.
> I will keep the loop variables unsigned though.
>

Yes, thank you.

Regards,
Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20211228/ba032b2a/attachment.htm>


More information about the lazarus mailing list