Re: Strength reduction of constant multipliers

sastdr@unx.sas.com (Thomas David Rivers)
Wed, 14 Oct 1992 18:54:00 GMT

          From comp.compilers

Related articles
Strength reduction of constant multipliers cliffc@cs.rice.edu (1992-10-13)
Re: Strength reduction of constant multipliers sastdr@unx.sas.com (1992-10-14)
Re: Strength reduction of constant multipliers sastdr@unx.sas.com (1992-10-15)
Strength reduction of constant multipliers cliffc@cs.rice.edu (1992-10-15)
Re: Strength reduction of constant multipliers davidm@voltaire.rational.com (1992-10-14)
Re: Strength reduction of constant multipliers preston@dawn.cs.rice.edu (1992-10-20)
| List of all articles for this month |

Newsgroups: comp.compilers
From: sastdr@unx.sas.com (Thomas David Rivers)
Organization: SAS Institute Inc.
Date: Wed, 14 Oct 1992 18:54:00 GMT
Keywords: arithmetic, optimize
References: 92-10-057

Interestingly enough, Dr. Dobbs Journal gave a nice example program for
doing strength reduction of constant multipliers.


Also, I have implemented that in the SAS/C Mainframe compiler, versions
5.00 and greater. My own testing indicated that for a simple algorithm,
sequences up to about 9/10 shift/add, shift/sub instructions beat a
multiply instruction hands down. Actually, I could reasonably claim that
the sequence could be as long as 14 instructions, but we settled on 9,
because of possible timing problems in the test. It's difficult to get
reliable numbers under MVS, and the timings can be vastly different for
the different IBM/370 implementations.


An interesting twist to the problem is that for the IBM/370, two adds are
faster than faster than a shift by 4. Making the problem of optimal
sequences even more difficult.


My goal, however, was not to provide optimal sequences, just something
better than a multiply instruction. The approach is to run a star chain
analysis, determining the length of the would-be sequence. If it is
greater than some threshold; (the aforementioned '9') use a multiply,
otherwise you've found something better.


        - Dave Rivers -
        (sastdr@unx.sas.com)
--


Post a followup to this message

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