diff options
Diffstat (limited to 'libc/arch-arm/bionic/memcpy.S')
-rw-r--r-- | libc/arch-arm/bionic/memcpy.S | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/libc/arch-arm/bionic/memcpy.S b/libc/arch-arm/bionic/memcpy.S index 2bdda5c..80f1bf5 100644 --- a/libc/arch-arm/bionic/memcpy.S +++ b/libc/arch-arm/bionic/memcpy.S @@ -426,23 +426,28 @@ memcpy: .text .fpu neon +#ifdef HAVE_32_BYTE_CACHE_LINE +/* a prefetch distance of 2 cache-lines */ +#define CACHE_LINE_SIZE 32 +#define PREFETCH_DISTANCE (CACHE_LINE_SIZE*2) +#else /* a prefetch distance of 4 cache-lines works best experimentally */ #define CACHE_LINE_SIZE 64 #define PREFETCH_DISTANCE (CACHE_LINE_SIZE*4) +#endif ENTRY(memcpy) .save {r0, lr} - stmfd sp!, {r0, lr} - /* start preloading as early as possible */ pld [r1, #(CACHE_LINE_SIZE*0)] + stmfd sp!, {r0, lr} pld [r1, #(CACHE_LINE_SIZE*1)] /* do we have at least 16-bytes to copy (needed for alignment below) */ cmp r2, #16 blo 5f - /* align destination to half cache-line for the write-buffer */ + /* align destination to cache-line for the write-buffer */ rsb r3, r0, #0 ands r3, r3, #0xF beq 0f @@ -471,6 +476,26 @@ ENTRY(memcpy) pld [r1, #(CACHE_LINE_SIZE*0)] pld [r1, #(CACHE_LINE_SIZE*1)] +#ifdef HAVE_32_BYTE_CACHE_LINE + /* make sure we have at least 32 bytes to copy */ + subs r2, r2, #32 + blo 4f + + /* preload all the cache lines we need. + * NOTE: the number of pld below depends on PREFETCH_DISTANCE, + * ideally would would increase the distance in the main loop to + * avoid the goofy code below. In practice this doesn't seem to make + * a big difference. + */ + pld [r1, #(PREFETCH_DISTANCE)] + +1: /* The main loop copies 32 bytes at a time */ + vld1.8 {d0 - d3}, [r1]! + pld [r1, #(PREFETCH_DISTANCE)] + subs r2, r2, #32 + vst1.8 {d0 - d3}, [r0, :128]! + bhs 1b +#else /* make sure we have at least 64 bytes to copy */ subs r2, r2, #64 blo 2f @@ -504,7 +529,7 @@ ENTRY(memcpy) subs r2, r2, #32 vst1.8 {d0 - d3}, [r0, :128]! bhs 3b - +#endif 4: /* less than 32 left */ add r2, r2, #32 tst r2, #0x10 |