aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crc32.c
diff options
context:
space:
mode:
authorJoakim Tjernlund <Joakim.Tjernlund@transmode.se>2012-01-10 18:10:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-10 19:30:51 -0500
commit5742332dea5560d6c449b007d9539dbdc8ee531b (patch)
tree64f4516b733638c966d6e66613e6ae016839d3f2 /lib/crc32.c
parentbfcb2cc798a14230d22b6dd999e2e680623de622 (diff)
crc32: optimize inner loop
Taking a pointer reference to each row in the crc table matrix, one can reduce the inner loop with a few insn's Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Cc: Bob Pearson <rpearson@systemfabricworks.com> Cc: Frank Zago <fzago@systemfabricworks.com> Cc: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/crc32.c')
-rw-r--r--lib/crc32.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index a6e633a48cea..4b35d2b4437c 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -51,20 +51,21 @@ static inline u32
51crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) 51crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256])
52{ 52{
53# ifdef __LITTLE_ENDIAN 53# ifdef __LITTLE_ENDIAN
54# define DO_CRC(x) crc = tab[0][(crc ^ (x)) & 255] ^ (crc >> 8) 54# define DO_CRC(x) crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8)
55# define DO_CRC4 crc = tab[3][(crc) & 255] ^ \ 55# define DO_CRC4 crc = t3[(crc) & 255] ^ \
56 tab[2][(crc >> 8) & 255] ^ \ 56 t2[(crc >> 8) & 255] ^ \
57 tab[1][(crc >> 16) & 255] ^ \ 57 t1[(crc >> 16) & 255] ^ \
58 tab[0][(crc >> 24) & 255] 58 t0[(crc >> 24) & 255]
59# else 59# else
60# define DO_CRC(x) crc = tab[0][((crc >> 24) ^ (x)) & 255] ^ (crc << 8) 60# define DO_CRC(x) crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)
61# define DO_CRC4 crc = tab[0][(crc) & 255] ^ \ 61# define DO_CRC4 crc = t0[(crc) & 255] ^ \
62 tab[1][(crc >> 8) & 255] ^ \ 62 t1[(crc >> 8) & 255] ^ \
63 tab[2][(crc >> 16) & 255] ^ \ 63 t2[(crc >> 16) & 255] ^ \
64 tab[3][(crc >> 24) & 255] 64 t3[(crc >> 24) & 255]
65# endif 65# endif
66 const u32 *b; 66 const u32 *b;
67 size_t rem_len; 67 size_t rem_len;
68 const u32 *t0=tab[0], *t1=tab[1], *t2=tab[2], *t3=tab[3];
68 69
69 /* Align it */ 70 /* Align it */
70 if (unlikely((long)buf & 3 && len)) { 71 if (unlikely((long)buf & 3 && len)) {