Re: Compiler optimization of division and remainder

richard@atheist.tamu.edu (Richard Henderson)
28 Jan 1996 16:53:42 -0500

          From comp.compilers

Related articles
Compiler optimization of division and remainder hbaker@netcom.com (1996-01-27)
Re: Compiler optimization of division and remainder d.sand@ix.netcom.com (1996-01-27)
Re: Compiler optimization of division and remainder augustss@cs.chalmers.se (1996-01-27)
Re: Compiler optimization of division and remainder richard@atheist.tamu.edu (1996-01-28)
Re: Compiler optimization of division and remainder prener@watson.ibm.com (1996-01-29)
Re: Compiler optimization of division and remainder hbaker@netcom.com (1996-01-29)
Re: Compiler optimization of division and remainder Peter-Lawrence.Montgomery@cwi.nl (1996-01-29)
Re: Compiler optimization of division and remainder johnmce@world.std.com (1996-01-29)
Re: Compiler optimization of division and remainder michael.williams@armltd.co.uk (1996-01-29)
Re: Compiler optimization of division and remainder jgj@ssd.hcsc.com (1996-01-29)
[2 later articles]
| List of all articles for this month |
From: richard@atheist.tamu.edu (Richard Henderson)
Newsgroups: comp.compilers
Date: 28 Jan 1996 16:53:42 -0500
Organization: Texas A&M University, College Station, TX
References: 96-01-088
Keywords: arithmetic, optimize

Henry G. Baker <hbaker@netcom.com> wrote:
>On another newsgroup, a poster claimed that some compilers could
>optimize a program which used both a/b and a%b (both quotient and
>remainder with the _same_ arguments) in such a way that the compiler
>would perform only a single hardware division operation and arrange to
>use both the quotient and remainder from this single operation.


In GCC, platforms that support this operation include a "divmod"
pattern in the machine description. This pattern forces both
operations to appear in the RTL so that, during CSE, when the
optimizer goes looking for where the value of the second operation
might already exist, it finds the value that was created previously.


The GCC texinfo documentation has a short blurb, but perusing the
source in and around expand_divmod() in expmed.c and the divmod
patterns in the config/*/*.md files will likely be more instructive.


r~
--


Post a followup to this message

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