All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] crc32: more optimizations
@ 2009-11-04  9:26 Joakim Tjernlund
  0 siblings, 0 replies; only message in thread
From: Joakim Tjernlund @ 2009-11-04  9:26 UTC (permalink / raw)
  To: u-boot

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);
-- 
1.6.4.4

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-04  9:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-04  9:26 [U-Boot] [PATCH] crc32: more optimizations Joakim Tjernlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.