Article View: gnu.gcc.bug
Article #2364Missed optimization in `gcc'
From: Derek Clegg
Date: Wed, 08 Mar 1989 16:32
Date: Wed, 08 Mar 1989 16:32
53 lines
1799 bytes
1799 bytes
/* Version:
* gcc version 1.34
* File:
* <this file>
* Problem:
* `gcc' fails to optimize fully in the case of dereference +
* autoincrement + pointer cast.
* Repeat by:
* % gcc -O -S <this file>
* Notes:
* `gcc' doesn't always take into account the size of the object pointed
* to by a pointer when dereferencing & autoincrementing. If the size is
* 1, 2, or 4 bytes, a simpler set of instructions could often be generated.
*
* The generated assembler isn't affected by any of the `-f' flags.
*
* gcc was compiled with `config.gcc sun3'.
* I am using a Sun 3/60 with UNIX 4.2 (Sun release 3.5).
*
* Derek B Clegg ({uunet,ucbcad,sun}!island!derek)
*/
void
xyzzy(int n, int *i1, int *i2, int k, char *s1, char *s2)
{
while (--n >= 0)
*i1++ = *i2++;
/*
* The above generates something similar to
* L4:
* movel a0@+,a1@+
* L2:
* subql #1,d0
* jpl L4
*/
while (--k >= 0)
*((int *)s1)++ = *((int *)s2)++;
/*
* This generates, however, something similar to
* L7:
* movel d2,a0
* addql #4,d2
* movel d1,a1
* addql #4,d1
* movel a1@,a0@
* L5:
* subql #1,d3
* jpl L7
*
* when, of course, the first sequence would be perfectly appropriate.
*/
}
Technical Details
Message-ID:
<8903081632.AA07825@fiji.island.uucp>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!island!fiji!derekShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!island!fiji!derek From: island!fiji!derek@UUNET.UU.NET (Derek Clegg) Newsgroups: gnu.gcc.bug Subject: Missed optimization in `gcc' Message-ID: <8903081632.AA07825@fiji.island.uucp> Date: 8 Mar 89 16:32:52 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 53