[Lazarus] Faster than popcnt [[Re: UTF8LengthFast returning incorrect results on AARCH64 (MacOS)]]

Martin Frb lazarus at mfriebe.de
Wed Dec 29 16:30:30 CET 2021

On 29/12/2021 13:42, Marco van de Voort via lazarus wrote:
> On 29-12-2021 10:16, Martin Frb via lazarus wrote:
>>> // Martin's routine that should be replaced by some punpkl magic, 
>>> but it is too late now.
>> Why too late?
> See datetime stamp.  02:10 AM. I don't know how it is with you Lazarus 
> devels, but we FPC devels need our beauty sleep from time to time.
Oh, too late for the day.
I thought. Too late, that ship has sailed.

> Could you post full source if you haven't already? For a bit of 
> benchmarking. I just wrote it from the top of my head, and I assumed 5 
> instructions for 16-byte would win any time, but haven't verified 
> anything yet.
I had it attached on my last mail. Attached it again here. (3rd 
procedure / "Utf8LengthAdd")

It is only 64bit for now. (And not cleaned up in any way).

Also changing "bc >> 7" and "bc and 127"
to "moddiv(bc, 255, full, remain)" might save a few more ms. But 
probably needs larger data to benchmark.

If you do work on this, feel free to integrate my code as the baseline 
for cpu without SSE.
Otherwise, it might be a bit until I get to it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Project1.pas
Type: application/x-unknown-content-type
Size: 6800 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20211229/62731496/attachment.bin>

More information about the lazarus mailing list