[fpc-devel] The "magic div" algorithm

J. Gareth Moreton gareth at moreton-family.com
Thu Sep 16 04:10:34 CEST 2021


The problem is that Free Pascal automatically scales up inputs to the 
word size, usually 32-bits.  If you do a node dump of a division node, 
you'll see that the input will often have a typecast node cast upon it.  
It is possible to remove it, but it would have to be done at a different 
compiler stage.  I might see if it's possible to implement this at a 
later stage, since I've done just that for my latest merge request for 
"(x mod n) = 0".

Gareth aka. Kit

On 15/09/2021 18:36, Marģers . via fpc-devel wrote:
> Hi,
> Thank you for implementation.
>
> Is that true, that you can not detect word and byte size on division 
> by constant? Squeezing in 32 bit register it would make byte-code 
> shorter, not necessarily faster.
> ----- Reply to message -----
> *Subject: *Re: [fpc-devel] The "magic div" algorithm
> *From: * J. Gareth Moreton via fpc-devel 
> <fpc-devel at lists.freepascal.org> <mailto:fpc-devel at lists.freepascal.org>
> *To: * <fpc-devel at lists.freepascal.org> 
> <mailto:fpc-devel at lists.freepascal.org>
>
>     This one is for Marģers especially:
>
>     https://gitlab.com/freepascal.org/fpc/source/-/issues/39355
>     <https://gitlab.com/freepascal.org/fpc/source/-/issues/39355>
>
>     Gareth aka. Kit
>
>
>
> _______________________________________________
> 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/20210916/6c65c364/attachment.htm>


More information about the fpc-devel mailing list