[U-Boot] [PATCH] crc32: more optimizations

Shave off yet 4 bytes and make if faster for unaligned and/or len & 3 != 0.
Signed-off-by: Joakim Tjernlund Joakim.Tjernlund@transmode.se ---
Now I am done with crc32 optimizations.
Someone should look at porting over crc32_be from linux since CRC32 BE is used by bzip and it could probably benefit from a faster CRC routine.
lib_generic/crc32.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib_generic/crc32.c b/lib_generic/crc32.c index 737587a..2837d93 100644 --- a/lib_generic/crc32.c +++ b/lib_generic/crc32.c @@ -188,30 +188,30 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t crc, const Bytef *buf, uInt len) crc = __cpu_to_le32(crc); /* Align it */ if(((long)b)&3 && len) { + uint8_t *p = (uint8_t *)b - 1; do { - uint8_t *p = (uint8_t *)b; - DO_CRC(*p++); - b = (void *)p; + DO_CRC(*++p); /* use pre increment for speed */ } while ((--len) && ((long)b)&3 ); + b = (uint32_t *)p + 1; }
save_len = len & 3; len = len >> 2; for (--b; len; --len) { /* load data 32 bits wide, xor data 32 bits wide. */ - crc ^= *++b; /* use pre increment below(*++b) for speed */ + crc ^= *++b; /* use pre increment for speed */ DO_CRC(0); DO_CRC(0); DO_CRC(0); DO_CRC(0); } - b++; /* point to next byte(s) */ len = save_len; /* And the last few bytes */ - for (; len; --len) { - uint8_t *p = (uint8_t *)b; - DO_CRC(*p++); - b = (void *)p; + if (len) { + uint8_t *p = (uint8_t *)(b++) - 1; + do { + DO_CRC(*++p); /* use pre increment for speed */ + } while (--len); }
return __le32_to_cpu(crc);
participants (1)
-
Joakim Tjernlund