Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!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.195853.27398@kithrup.COM> Date: 14 Mar 91 19:58:53 GMT References: <7571@mentor.cc.purdue.edu> <1991Mar14.013109.16636@kithrup.COM> <7850@mentor.cc.purdue.edu> Organization: Kithrup Enterprises, Ltd. Lines: 47 In article <7850@mentor.cc.purdue.edu> hrubin@pop.stat.purdue.edu (Herman Rubin) writes: >| pushl %ebp >| pushl %ebx >| movl 8(%ebp),%eax >| idivl 12(%ebp) >| pushl %ebx >| pushl %ecx >| pushl $.LC0 >| leal -4(%ebp),%esp >| popl %ebx >> >This example has far too many loads and stores. 9 memory references. 4 necessary for the calling sequence gcc conforms to. Three necessary to call another function, since the 'bcs' does not specify calling routines with values in registers. Two more because arguments passed in are not in registers. Leaving a total of 0 unnecessary loads and stores. Could this be improved? Certainly. But not by much. >Possibly this MIGHT not be >too important for a division, but how about something like frexp? I think it was frexp() that I wrote for berkeley using gcc with inline assembly. Uhm... I think it had 7 loads and stores, all but two or three of which would disappear if the function got inlined and optimized. >The >operations may be register-register, in which case all these loads and >stores are inappropriate. Herman: where are you supposed to get the values from? Magic? >Also, something this simple should be inlined; >if a subroutine call, there is the additional save/restore overhead which >has to be done somewhere. Jesus. Guess what, herman: the routine *was* inlined. Take a look at the original source code again. I think you're just complaining because you seem to thing there's something wrong, when there really isn't. -- 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.