[llvm-commits] [patch] call libc memcpy/memset for big arrays
Dale Johannesen
dalej at apple.com
Fri Aug 24 22:08:13 PDT 2007
On Aug 24, 2007, at 6:15 PM, Chris Lattner wrote:
>
> On Aug 24, 2007, at 4:44 AM, Rafael Espindola wrote:
>
>> Currently we expand a memcpy/memset node to a call to the libc
>> implementation if
>>
>> if ((Align & 3) != 0 ||
>> (I && I->getValue() < Subtarget->getMinRepStrSizeThreshold
>> ())) {
>>
>> Shouldn't this be a ">". The libc memcpy/memset are very fast for
>> big arrays.
Do you have data to support this? It is dependent on the OS (well
libc really) and target CPU for sure.
> Yep, that makes sense to me! Please commit.
>
> Dale, please review the commit when you get a chance,
Intuitively it looks OK. I'd like to see numbers, but I doubt that
spending a lot of time on this is productive.
I've spent way too much time playing with the heuristics for memcpy
expansion. My firmest conclusion is that, whatever the compiler
does, somebody will supply an example where it is better to do
something else.:)
The situation is especially bad on x86 since different things are
optimal for different CPUs, and compiled code will typically run on
more than one CPU. Here are some numbers from the last time I looked
at it: http://gcc.gnu.org/ml/gcc-patches/2005-08/msg01614.html
On that CPU and OS (Darwin 10.4, IIRC), it was never right to use rep/
mov, and the library function didn't look too good compared to
repeated lod/sto. ymmv.
> -Chris
>
>> If I compile
>>
>> ---------------------------------------
>> #include <string.h>
>> void f1(long *a, long *b) {
>> memcpy(a, b, 8 * 16);
>> }
>>
>> void f2(long *a, long *b) {
>> memcpy(a, b, 8 * 32);
>> }
>> ---------------------------------------
>>
>> with gcc 4.2 (-O2), it will call memcpy for f2 and not for f1.
>>
>> Cheers,
>> --
>> Rafael Avila de Espindola
>>
>> Google Ireland Ltd.
>> Gordon House
>> Barrow Street
>> Dublin 4
>> Ireland
>>
>> Registered in Dublin, Ireland
>> Registration Number: 368047
>> <memcpy.patch>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list