<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Dec 28, 2021 at 1:45 PM Bart via lazarus <<a href="mailto:lazarus@lists.lazarus-ide.org">lazarus@lists.lazarus-ide.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">@Juha: can you please comment on my possible improvement using PopCnt<br>
instead of a multiplication with ONEMASK.<br></blockquote><div><br></div><div>I confess I didn't remember what PopCnt does. I checked from the net.</div><div><div>FPC implements it as internproc.</div><div> function PopCnt(Const AValue : QWord): QWord;[internproc:fpc_in_popcnt_x];</div></div><div>I guess it translates to one x86_64 instruction.</div><div>Is it implemented for all CPUs? I found this:</div><div> <a href="https://gitlab.com/freepascal.org/fpc/source/-/issues/38729">https://gitlab.com/freepascal.org/fpc/source/-/issues/38729</a><br></div><div>If it works everywhere, good. It looks like another good optimization for this highly optimized function.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I will patch the function using unsigned types where applicable.<br>
I will keep the loop variables unsigned though.<br></blockquote><div><br></div><div>Yes, thank you.</div><div><br></div><div>Regards,</div><div>Juha</div><div><br></div></div></div></div></div></div></div>