Path: utzoo!news-server.csri.toronto.edu!bonnie.concordia.ca!ccu.umanitoba.ca!herald.usask.ca!alberta!ubc-cs!uw-beaver!cornell!llenroc!batcomputer!caen!zaphod.mps.ohio-state.edu!wuarchive!csus.edu!nic.csu.net!csun!kithrup!sef From: sef@kithrup.COM (Sean Eric Fagan) Newsgroups: comp.arch Subject: Re: Unusual instructions and constructions Message-ID: <1991Mar14.013109.16636@kithrup.COM> Date: 14 Mar 91 01:31:09 GMT References: <4748@eastapps.East.Sun.COM> <7571@mentor.cc.purdue.edu> <11964@pasteur.Berkeley.EDU> Organization: Kithrup Enterprises, Ltd. Lines: 38 In article <11964@pasteur.Berkeley.EDU> jbuck@galileo.berkeley.edu (Joe Buck) writes: >Check out this short program: [code deleted] >It's not optimal: there are two divides. Still, if you write kindly >I'll bet you could talk RMS into seeing if he could recognize the >pattern and produce one divide in gcc 2.0 (or for some higher number). foop: pushl %ebp movl %esp,%ebp pushl %ebx movl 8(%ebp),%eax cltd idivl 12(%ebp) movl %eax,%ecx movl %edx,%ebx pushl %ebx pushl %ecx pushl $.LC0 call printf leal -4(%ebp),%esp popl %ebx leave ret It was already done, for gcc 1.3[89]. Good work, eh? Yes, the code could be optimal: gcc could look at the entire function, and not bother moving from eax to ecx, just pushing them directly. But those are small amounts (two or three cycles, I believe), and are *much* better than the 15+ cycles the extra divide would have taken. -- Sean Eric Fagan | "I made the universe, but please don't blame me for it; sef@kithrup.COM | I had a bellyache at the time." -----------------+ -- The Turtle (Stephen King, _It_) Any opinions expressed are my own, and generally unpopular with others.