This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: memcpy / Language Lawyer / optimization question


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]