This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, mips] Faster strcmp for mips


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]