Xref: utzoo unix-pc.general:869 comp.sys.att:3551 Path: utzoo!utgpu!water!watmath!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!ig!uwmcsd1!vanvleck!uwvax!oddjob!ncar!noao!arizona!naucse!rrr From: rrr@naucse.UUCP (Bob Rose ) Newsgroups: unix-pc.general,comp.sys.att Subject: Re: GNU C Message-ID: <742@naucse.UUCP> Date: 21 Jun 88 03:55:36 GMT References: <1118@unisec.usi.com> <1015@umbc3.UMD.EDU> <735@naucse.UUCP> <192@elgar.UUCP> Organization: Northern Arizona University, Flagstaff, AZ Lines: 61 In article <192@elgar.UUCP>, ford@elgar.UUCP (Mike "Ford" Ditto) writes: > In article <735@naucse.UUCP> rrr@naucse.UUCP (Bob Rose ) writes: > >In article <1015@umbc3.UMD.EDU>, alex@umbc3.UMD.EDU (Alex S. Crain) writes: > > > BTW: I use gcc-1.18 as my default compiler because I find ... > > > >I'm not sure about this. The way gcc does an interger multiply is gross! > >(it calls a routine that calls a routine that does a multiply) > > Since the 68010 has no 32-bit multiply instruction, a library function > is the best way for the compiler to do it. The call-a-routine-that- > calls-a-routine is only if you haven't configured gcc to call the > standard library routine (the same one that the normal C compiler > uses). Gcc then will deffault to the multiply routine in the "gnulib" > library which really only exists for such "stub" routines. I've spent the last two week's doing some major hacking to gcc. And oooh some of the fun things I've seen. First if you let gcc default the multiply instruction you get a function call to `mulsi3' which is just the C function int mulsi3(a,b) {return a*b;} (This of course must be compiled with cc, not gcc) So the following C code gets compiled by gcc as C code Asm a = b*f() jsr f mov.l d0,-(sp) mov.l b,-(sp) jsr mulsi3 mov.l d0,a Now if you muck around you can force the first arguement of a library call to be in d0 so the code becomes C code Asm a = b*f() jsr f mov.l b,-(sp) jsr muls__ # the standard routine mov.l d0,a Pretty neat and it saves two move instructions (one of them is in the multiply routine.) So lets compile this code C code Asm a = f()*b jsr f mov.l d0,d2 mov.l b,d0 mov.l d2,-(sp) jsr muls__ # the standard routine mov.l d0,a Gag me with a spoon! Gcc has forgot that multiply is reflexive (because it has been turned into a function call.) If you try to tell gcc that multiply is not a function call on the 68000 you screw up the stack. Now is all this mucking around worth it. I think so, I have gotten a 20% improvement in drystones 2.0. (Note this version of gcc in not fully debugged yet, it trashes a few registers.) If you (or alex) have gotten gcc to link to the standard routines in a reasonable manner, I would sure like the diff's. -bob