This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: memcpy / Language Lawyer / optimization question
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Steve Ellcey <sje at cup dot hp dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 9 Dec 2004 12:14:05 -0800
- Subject: Re: memcpy / Language Lawyer / optimization question
- References: <200412091932.LAA06762@hpsje.cup.hp.com>
On Thu, Dec 09, 2004 at 11:32:55AM -0800, Steve Ellcey wrote:
> [ unaligned int and memcpy ]
...
> I ran into this in the libgfortran where I am trying to replace an
> assignment of a long into a (possibly) unaligned buffer with a call to
> memcpy.
I misunderstood your original question. The issue of lying to the
compiler is still an important matter: if the user calls memcpy, a
standard function, the compiler is allowed to optimize it based on the
rules of C. It is very dangerous to find a case that gcc currently
does not optimize, and rely on this to do aligned word copies, because
future work on gcc is likely to break this.
One approach would be to force a call to the real memcpy. Ideally, there
would be a hook that would specify that an unaligned transfer must be
done, even in a case that appears aligned based on the type system.