From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1486 invoked by alias); 18 Nov 2013 23:50:26 -0000 Mailing-List: contact libc-ports-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: libc-ports-owner@sourceware.org Received: (qmail 1477 invoked by uid 89); 18 Nov 2013 23:50:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_40,FREEMAIL_FROM,RDNS_NONE,SPF_NEUTRAL,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Received: from Unknown (HELO popelka.ms.mff.cuni.cz) (195.113.20.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2013 23:50:24 +0000 Received: from domone.kolej.mff.cuni.cz (popelka.ms.mff.cuni.cz [195.113.20.131]) by popelka.ms.mff.cuni.cz (Postfix) with ESMTPS id 308DD168B; Tue, 19 Nov 2013 00:50:13 +0100 (CET) Received: by domone.kolej.mff.cuni.cz (Postfix, from userid 1000) id 017585F771; Tue, 19 Nov 2013 00:50:12 +0100 (CET) Date: Tue, 19 Nov 2013 02:32:00 -0000 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: Steve Ellcey Cc: libc-ports@sourceware.org Subject: Re: [Patch, mips] Faster strcmp for mips Message-ID: <20131118235011.GA10609@domone.podge> References: <1384464221.2484.86.camel@ubuntu-sellcey> <20131114231434.GA5331@domone.podge> <1384539604.2484.102.camel@ubuntu-sellcey> <20131115190200.GA28546@domone.podge> <1384817878.2484.137.camel@ubuntu-sellcey> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1384817878.2484.137.camel@ubuntu-sellcey> User-Agent: Mutt/1.5.20 (2009-06-14) X-SW-Source: 2013-11/txt/msg00035.txt.bz2 On Mon, Nov 18, 2013 at 03:37:58PM -0800, Steve Ellcey wrote: > On Fri, 2013-11-15 at 20:02 +0100, Ondřej Bílka wrote: > > > I decided that using ffls was shorter but for some reasons I kept > > bitfirst there. A correct version is > > > > uint64_t bitmask = DETECTNULL8(x) | (x ^ y); > > int pos = (ffsl(bitmask) - 1) / 8; > > return a[pos] - b[pos]; > > Yes, that works much better. But it only works in little-endian mode. I > think I would need a fls (find last set) or something similar for > big-endian wouldn't I? Or else I would need to swap the bytes around > before using ffs/ffsl. > Yes, a correct function is __builtin_clzl. Difference from ffs is that when you pass zero then result is undefined which should not be problem here. There are more builtins here: http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html