Some archs(RISC like archs) can do pre increment and load in one insn but gcc optimization often fails to take advantage of that. Help gcc to do the right thing by using pre increment instead of post increment.
Signed-off-by: Joakim Tjernlund <joakim.tjernl...@transmode.se> --- lib/checksum.c | 8 +++----- 1 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/checksum.c b/lib/checksum.c index cd0fefd..2e427a2 100644 --- a/lib/checksum.c +++ b/lib/checksum.c @@ -72,11 +72,9 @@ ipsum_calc_block(u16 *x, unsigned len, u16 sum) len >>= 1; tmp = 0; xx = (u32 *) x; - while (len) - { - tmp = add32(tmp, *xx++); - len--; - } + for (xx--; len; --len); + tmp = add32(tmp, *++xx); + xx++; sum = add16(sum, add16(tmp & 0xffff, tmp >> 16U)); if (rest) sum = add16(sum, *(u16 *) xx); -- 1.6.4.4