From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757136Ab1HaWaN (ORCPT ); Wed, 31 Aug 2011 18:30:13 -0400 Received: from cdptpa-bc-oedgelb.mail.rr.com ([75.180.133.33]:36603 "EHLO cdptpa-bc-oedgelb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756945Ab1HaWaH (ORCPT ); Wed, 31 Aug 2011 18:30:07 -0400 Authentication-Results: cdptpa-bc-oedgelb.mail.rr.com smtp.user=rpearson@systemfabricworks.com; auth=pass (PLAIN) X-Authority-Analysis: v=1.1 cv=40Z/dbZBr1wgzPkGSf8y7qdCkiWp+M7NvixVUiz+qMg= c=1 sm=0 a=eBnEfeSLl9YA:10 a=AedyWO0V8NIA:10 a=ozIaqLvjkoIA:10 a=8nJEP1OIZ-IA:10 a=DCwX0kaxZCiV3mmbfDr8nQ==:17 a=YORvzBCaAAAA:8 a=RbKqfa4Q34oRV1Xdn4oA:9 a=oET8QQufpMVZFVt5IJsA:7 a=wPNLvfGTeEIA:10 a=VV2__AUApEoA:10 a=DCwX0kaxZCiV3mmbfDr8nQ==:117 X-Cloudmark-Score: 0 X-Originating-IP: 67.79.195.91 Message-ID: <4E5EB5EE.806@systemfabricworks.com> Date: Wed, 31 Aug 2011 17:30:06 -0500 From: Bob Pearson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110805 Thunderbird/3.1.12 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org CC: fzago@systemfabricworks.com, rpearson@systemfabricworks.com, Joakim Tjernlund , George Spelvin , akpm@linux-foundation.org Subject: [PATCH v6 04/10] crc32-add-pointer-to-tab.diff References: <20110831213729.395283830@systemfabricworks.com> In-Reply-To: <20110831213729.395283830@systemfabricworks.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace 2D array references by pointer references in loops. This change has no effect on X86 code but improves PPC performance. Signed-off-by: Bob Pearson --- lib/crc32.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) Index: for-next/lib/crc32.c =================================================================== --- for-next.orig/lib/crc32.c +++ for-next/lib/crc32.c @@ -53,20 +53,21 @@ static inline u32 crc32_body(u32 crc, unsigned char const *buf, size_t len, const u32 (*tab)[256]) { # ifdef __LITTLE_ENDIAN -# define DO_CRC(x) crc = tab[0][(crc ^ (x)) & 255] ^ (crc >> 8) -# define DO_CRC4 crc = tab[3][(crc) & 255] ^ \ - tab[2][(crc >> 8) & 255] ^ \ - tab[1][(crc >> 16) & 255] ^ \ - tab[0][(crc >> 24) & 255] +# define DO_CRC(x) (crc = t0[(crc ^ (x)) & 255] ^ (crc >> 8)) +# define DO_CRC4 crc = t3[(crc) & 255] ^ \ + t2[(crc >> 8) & 255] ^ \ + t1[(crc >> 16) & 255] ^ \ + t0[(crc >> 24) & 255] # else -# define DO_CRC(x) crc = tab[0][((crc >> 24) ^ (x)) & 255] ^ (crc << 8) -# define DO_CRC4 crc = tab[0][(crc) & 255] ^ \ - tab[1][(crc >> 8) & 255] ^ \ - tab[2][(crc >> 16) & 255] ^ \ - tab[3][(crc >> 24) & 255] +# define DO_CRC(x) (crc = t0[((crc >> 24) ^ (x)) & 255] ^ (crc << 8)) +# define DO_CRC4 crc = t0[(crc) & 255] ^ \ + t1[(crc >> 8) & 255] ^ \ + t2[(crc >> 16) & 255] ^ \ + t3[(crc >> 24) & 255] # endif const u32 *b; size_t rem_len; + const u32 *t0 = tab[0], *t1 = tab[1], *t2 = tab[2], *t3 = tab[3]; /* Align it */ if (unlikely((long)buf & 3 && len)) {