GNU C
Bob Rose
rrr at naucse.UUCP
Tue Jun 21 13:55:36 AEST 1988
In article <192 at elgar.UUCP>, ford at elgar.UUCP (Mike "Ford" Ditto) writes:
> In article <735 at naucse.UUCP> rrr at naucse.UUCP (Bob Rose ) writes:
> >In article <1015 at umbc3.UMD.EDU>, alex at 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
More information about the Unix-pc.general
mailing list