Re: [PATCH] fs/fat: calculate checksum in a loop instead of directly calculating

From: OGAWA Hirofumi
Date: Wed Feb 18 2015 - 14:26:03 EST


Alexander Kuleshov <kuleshovmail@xxxxxxxxx> writes:

> static inline unsigned char fat_checksum(const __u8 *name)
> {
> + u8 i;
> unsigned char s = name[0];
> - s = (s<<7) + (s>>1) + name[1]; s = (s<<7) + (s>>1) + name[2];
> - s = (s<<7) + (s>>1) + name[3]; s = (s<<7) + (s>>1) + name[4];
> - s = (s<<7) + (s>>1) + name[5]; s = (s<<7) + (s>>1) + name[6];
> - s = (s<<7) + (s>>1) + name[7]; s = (s<<7) + (s>>1) + name[8];
> - s = (s<<7) + (s>>1) + name[9]; s = (s<<7) + (s>>1) + name[10];
> +
> + for (i = 1; i < 11; i++)
> + s = (s << 7) + (s >> 1) + name[i];
> +
> return s;
> }

When I wrote this, IIRC, there was measurable performance
difference. All major gcc versions are enough smart now to optimize this?
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/