[fpc-devel] The "magic div" algorithm

J. Gareth Moreton gareth at moreton-family.com
Fri Aug 20 20:52:38 CEST 2021


Something tells me I should purchase that book - I sense it could reveal 
some interesting insights.

Note that while I understand the concept of turning integer division 
into multiplication (indeed, I implemented the first version into x86 
before it was improved with the "calc_divconst_magic_unsigned" routine, 
and then implemented it for AArch64), the algorithm that is used in 
"calc_divconst_magic_unsigned" I don't quite get if just for the lack of 
comments and references, although I am studying it more closely.

Still, I figure I'll put down Hacker's Delight as a future purchase so I 
have a reputable source rather than just an online one (I know there's 
one somewhere that isn't behind a paywall).

Gareth aka. Kit

On 20/08/2021 18:46, Marģers . via fpc-devel wrote:
>
>      is there a reference to the algorithm that's used to calculate the
>     reciprocal constants used in the integer division optimisations
>     for x86 and AArch64?
>
>
> Hacker’s Delight
> Second Edition
> Henry S. Warren, Jr.
>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


-- 
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20210820/680e5a41/attachment.htm>


More information about the fpc-devel mailing list