This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Autoincrement examples
- To: "GCC mailing list" <gcc at gcc dot gnu dot org>
- Subject: Re: Autoincrement examples
- From: "Rask Ingemann Lambertsen" <rask at kampsax dot k-net dot dk>
- Date: 29 Sep 99 12:45:22 +0100
- Organization: Me? Organised? Dream on...
Den 22-Sep-99 11:08:25 skrev Bernd Schmidt fĝlgende om "Autoincrement examples":
> If someone has (preferrably small) example code (for any target), which
> shows how the compiler generates auto-increments either very well or very
> badly,
This particular example has long been a pet peeve of mine wrt. GCC code
generation on m68k:
void stringcopy (const char *src, char *dest)
{
while (*dest++ = *src++)
;
}
GCC 2.95.1 generates this code for the loop body:
L5:
moveb a1@+,a0@
tstb a0@+
jne L5
That sort of code will give any m68k programmer red eyes, since the tstb
instruction is unneeded. The loop body should be just
L5:
moveb a1@+,a0@+
jne L5
In particular on the 68010, the latter loop should be quite a bit
faster (2*strlen(src) + 2 memory accesses instead of 5*strlen(src) memory
accesses.
Regards,
/ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻTŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\
| Rask Ingemann Lambertsen | E-mail: mailto:rask@kampsax.k-net.dk |
| Registered Phase5 developer | WWW: http://www.gbar.dtu.dk/~c948374/ |
| A4000, 866 kkeys/s (RC5-64) | "ThrustMe" on XPilot, ARCnet and IRC |
| If it jams, force it. If it breaks, it needed replacing. |