Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754873AbbBRTZ6 (ORCPT ); Wed, 18 Feb 2015 14:25:58 -0500 Received: from mail.parknet.co.jp ([210.171.160.6]:41281 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752540AbbBRTZ5 (ORCPT ); Wed, 18 Feb 2015 14:25:57 -0500 From: OGAWA Hirofumi To: Alexander Kuleshov Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs/fat: calculate checksum in a loop instead of directly calculating References: <1424285300-14431-1-git-send-email-kuleshovmail@gmail.com> Date: Thu, 19 Feb 2015 04:25:54 +0900 In-Reply-To: <1424285300-14431-1-git-send-email-kuleshovmail@gmail.com> (Alexander Kuleshov's message of "Thu, 19 Feb 2015 00:48:20 +0600") Message-ID: <878ufvowcd.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1015 Lines: 27 Alexander Kuleshov 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/