This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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 2/*] Optimize generic strchrnul and strchr


On 05/27/2015 12:02 PM, OndÅej BÃlka wrote:
The other thing is support for big-endian - this is generally tricky as
>the mask returned by the zero check won't work even if byte-reversed.
>
Nice catch, didn't though about that. Short answer is that you need a
more complicated expression that doesn't cause carry propagation like

(((x | 128) - 127) ^ 128) & ~x & 128

Then you could do byte reversal but its isnt needed as it would be
faster to count leading zero bytes directly.

So we will need add separate BIG_ENDIAN_EXPRESSION macro to support
these. Possibly one could squeeze extra performance if he is more
careful but I don't care that much.

Then first_nonzero_byte would need some work to support that, you could
do it directly without reversing.


See sysdeps/tile/tilegx/strchrnul.c, which uses a string-endian.h
header to manage bigendian mode.

--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com


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