m68k cross 'link' and 'unlk' waste

Petter Reinholdtsen pere@hungry.com
Sun Dec 12 04:28:00 GMT 1999


When using GCC 2.95.2 as a cross compiler to m68k (68332), it includes
'link' and 'unlk' instructions even when the stack isn't used.

The following code:

  static int myvar = 0;
  int
  smallfunc(void)
  {
    return myvar;
  }

results in the following assembly output:

  .globl smallfunc
  smallfunc:
	link.w %a6,#0
	move.l myvar,%d0
	unlk %a6
	rts

In this function, the stack is unused, and both link.w and unlk
instructions should be removed:

  .globl smallfunc
  smallfunc:
	move.l myvar,%d0
	rts

We use the m68332 CPU as a Robot controller.  When doing real time
applications, every cycle saved counts. :-)
-- 
##>  Petter Reinholdtsen <##    | pere@td.org.uit.no
 O-  <SCRIPT Language="Javascript">window.close()</SCRIPT>
http://www.hungry.com/~pere/    | Go Mozilla, go! Go!


More information about the Gcc-bugs mailing list