This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

m68k code generation


I still think there is something wrong with divsi3 at least. Here is
some code I compiled and the objdump of it. The muls seem OK, but why
does only the constant divide get a divs.w whereas the first divide with
a var turn into a libcall??

short i=9999,j=9999,k=9999;

int main(void)
{
    j = i / j;
    k = i / 9999;
    i = k * j;
    k = j * 9999;
}

004085bc <main>:
  4085bc: 4e56 0000       linkw %fp,#0
  4085c0: 2f02            movel %d2,%sp@-
  4085c2: 4eb9 0040 868a  jsr 40868a <__main>

  4085c8: 3079 0000 800a  moveaw 800a <j>,%a0
  4085ce: 2f08            movel %a0,%sp@-
  4085d0: 3279 0000 8008  moveaw 8008 <i>,%a1
  4085d6: 2f09            movel %a1,%sp@-
  4085d8: 4eb9 0040 86a8  jsr 4086a8 <__divsi3>  ***WHY???
  4085de: 33c0 0000 800a  movew %d0,800a <j>

  4085e4: 3239 0000 8008  movew 8008 <i>,%d1
  4085ea: 48c1            extl %d1
  4085ec: 83fc 270f       divsw #9999,%d1		 ***GOOD!!!
  4085f0: 33c1 0000 800c  movew %d1,800c <k>

  4085f6: c3c0            mulsw %d0,%d1
  4085f8: 33c1 0000 8008  movew %d1,8008 <i>

  4085fe: c1fc 270f       mulsw #9999,%d0
  408602: 33c0 0000 800c  movew %d0,800c <k>

  408608: 242e fffc       movel %fp@(-4),%d2
  40860c: 4e5e            unlk %fp
  40860e: 4e75            rts

Another thing I noticed is the following code:

int main(void)
{
   int i;
   for ( i = 100; i > 0; i -- )
	Function();
}

generates:
00000098 <main>:
  98:	4e56 0000      	linkw %fp,#0
  9c:	2f0a           	movel %a2,%sp@-
  9e:	2f02           	movel %d2,%sp@-
  a0:	4eb9 0000 0000 	jsr 0 <.text>
  a6:	7464           	moveq #100,%d2
  a8:	45f9 0000 0000 	lea 0 <.text>,%a2
  ae:	4e92           	jsr %a2@
  b0:	5382           	subql #1,%d2         \ Can't these be
  b2:	4a82           	tstl %d2              )a DBcc??
  b4:	6ef8           	bgts ae <main+0x16>  /
  b6:	242e fff8      	movel %fp@(-8),%d2
  ba:	246e fffc      	moveal %fp@(-4),%a2
  be:	4e5e           	unlk %fp
  c0:	4e75           	rts

Sorry if I seem picky <grin>, but I am curious as to the history of the
m68k port and how "good" it is...and if there *is* room for improvement,
would it be generally desired?

Paul.

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]