Re: Multiplication by a constant - how?

rweaver@ix.netcom.com (Richard Weaver )
16 Mar 1997 23:05:12 -0500

          From comp.compilers

Related articles
Multiplication by a constant - how? Sergey.Solyanik@bentley.com (Sergey Solyanik) (1997-03-14)
Re: Multiplication by a constant - how? rweaver@ix.netcom.com (1997-03-16)
Re: Multiplication by a constant - how? harwood@trinidad.progress.com (1997-03-16)
Re: Multiplication by a constant - how? d.sand@ix.netcom.com (Duane Sand) (1997-03-16)
Re: Multiplication by a constant - how? harwood@trinidad.progress.com (1997-03-16)
Re: Multiplication by a constant - how? dlmoore@ix.netcom.com (David L Moore) (1997-03-16)
Re: Multiplication by a constant - how? preston@tera.com (1997-03-21)
Re: Multiplication by a constant - how? torbenm@diku.dk (1997-03-21)
[3 later articles]
| List of all articles for this month |

From: rweaver@ix.netcom.com (Richard Weaver )
Newsgroups: comp.compilers
Date: 16 Mar 1997 23:05:12 -0500
Organization: Netcom
References: 97-03-062
Keywords: arithmetic, optimize

Sergey Solyanik <Sergey.Solyanik@bentley.com> writes:
>MicroSoft Visual C seems to be capable to generate multiplication by a
>constant using sequence of shifts and adds no longer than 6 operations
>(total), using at most two registers. The optimization is used always
>and does not seem to be confined to any special cases. Does anybody
>know what algorithm is used and where can I look for information?
...


One source for this algorithm is


    Richard J. Gillings
    Mathematics in the Time of the Pharaohs
    MIT, 1972


    Dover reprint 1982


From page 18 "When the Egyptian scribe needed to multiply two numbers,
he would first decide which would be the multiplicand, then he would
repeatedly multiply this by 2, adding up the intermediate multipliers
until they summed to the original multiplier"


Dick W
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.