From: "Ondřej Bílka" <neleai@seznam.cz>
To: Steve Ellcey <sellcey@mips.com>
Cc: libc-ports@sourceware.org
Subject: Re: [Patch, mips] Faster strcmp for mips
Date: Tue, 19 Nov 2013 02:32:00 -0000 [thread overview]
Message-ID: <20131118235011.GA10609@domone.podge> (raw)
In-Reply-To: <1384817878.2484.137.camel@ubuntu-sellcey>
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
next prev parent reply other threads:[~2013-11-18 23:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 21:25 Steve Ellcey
2013-11-14 23:14 ` Ondřej Bílka
2013-11-15 18:21 ` Steve Ellcey
2013-11-15 19:02 ` Ondřej Bílka
2013-11-18 23:50 ` Steve Ellcey
2013-11-19 2:32 ` Ondřej Bílka [this message]
2013-11-15 18:48 ` Carlos O'Donell
2013-11-15 18:53 ` Steve Ellcey
2013-11-15 18:59 ` Carlos O'Donell
2015-02-19 7:25 ` Matt Turner
2015-02-19 18:12 ` Steve Ellcey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131118235011.GA10609@domone.podge \
--to=neleai@seznam.cz \
--cc=libc-ports@sourceware.org \
--cc=sellcey@mips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).