missed optimization in m68k

Alan Lehotsky apl@alum.mit.edu
Fri Jun 14 17:53:00 GMT 2002


You need to look at the RTL.

I suspect that you'll find you get better code (BTW) if you did

	{
	  int dst0 = (int) dst;
	.....

	  return (char *)dst0;
	}

Although I admit that type hacks like that are shameful.

What you REALLY ought to do is to implement the "movstrqi" pattern 
and let the compiler do inline string copy instead of worrying about 
these code patterns.....

== Al


At 7:46 PM -0400 6/14/02, Peter Barada wrote:
>Ugghh, way to much work going on here.  I got this *all* wrong.
>I'll start over....
>
>When I compile:
>
>char *copy(const char *src, char *dst)
>{
>   char *dst0 = dst;
>   while (*dst++ = *src++)
>     ;
>   return dst0;
>}
>
>using a ColdFire v4e modified verion of 3.0.4 using '-mc68020 -O4
>-fomit-frame-pointer' I get:
>
>copy:
>	move.l %a2,-(%sp)
>	move.l 8(%sp),%a1
>	move.l 12(%sp),%a0
>	move.l %a0,%a2
>.L2:
>	move.b (%a1)+,(%a0)
>	tst.b (%a0)+
>	jbne .L2
>	move.l %a2,%d0
>	move.l (%sp)+,%a2
>	rts
>
>When I compile it using '-mcfv4e -O4' using the same 3.0.4 v4e
>modified compiler I get:
>
>copy:
>	move.l 4(%sp),%a1
>	move.l 8(%sp),%a0
>	move.l %a0,%d0
>.L2:
>	move.b (%a1)+,(%a0)
>	tst.b (%a0)+
>	jbne .L2
>	rts
>
>So I'm wondering where to check for the extra move of %a0 to %a2 came
>from instead of moveing it to %d0.
>
>Any ideas will be most appreciated.  TIA...


-- 
		    Quality Software Management
		http://home.earthlink.net/~qsmgmt
		          apl@alum.mit.edu
		          (978)287-0435 Voice
		          (978)808-6836 Cell

	Software Process Improvement / Management Consulting
	     Language Design / Compiler Implementation



More information about the Gcc mailing list