Re: Compiler optimization of division and remainder

Dave Lloyd <dave@occl-cam.demon.co.uk>
29 Jan 1996 23:22:25 -0500

          From comp.compilers

Related articles
[4 earlier articles]
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)
Re: Compiler optimization of division and remainder dave@occl-cam.demon.co.uk (Dave Lloyd) (1996-01-29)
Re: Compiler optimization of division and remainder dave@occl-cam.demon.co.uk (Dave Lloyd) (1996-02-02)
| List of all articles for this month |
From: Dave Lloyd <dave@occl-cam.demon.co.uk>
Newsgroups: comp.compilers
Date: 29 Jan 1996 23:22:25 -0500
Organization: Compilers Central
References: 96-01-088
Keywords: arithmetic, optimize

hbaker@netcom.com (Henry G. Baker) writes:
      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.


We do this on the x86 where the idiv instruction plonks the quotient
in AX and the remainder in DX. Most other processors either don't have
hardware support or only give you one of the values out of the divide
unit depending on source instruction.


One can play a similar game with other multiple-output instructions:
for example, one gets given both the sin and the cos out of a chordic
algorithm and in many circumstances sin(x) and cos(x) get used
together.


----------------------------------------------------------------------
Dave Lloyd Email: Dave@occl-cam.demon.co.uk
Oxford and Cambridge Compilers Ltd Phone: (44) 1223 572074
55 Brampton Rd, Cambridge CB1 3HJ, UK
--


Post a followup to this message

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