Re: [PATCH] optimize ia32 memmove

From: Linus Torvalds
Date: Tue Dec 30 2003 - 05:02:16 EST




On Tue, 30 Dec 2003, Jeff Garzik wrote:
>
> I'm confused... that doesn't say anything to me about overlap.
>
> They can still overlap: Consider if dest is 1 byte less than src, and
> n==128...

But then anything that does the loads in ascending order is still ok, so
it shouldn't matter - by the time "dest" has been overwritten, the source
data has already been read. And all the "memcpy()" implementations had
better do that anyway, in order to get nice memory access patterns. "rep
movsl" certainly does.

So assuming we have an ascending "memcpy()", the only case we need to care
about is "overlap && dest > src".

Now, if we have a non-ascending memcpy(), we have trouble.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/