Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160919132953.GA8375@dell12.lru.li>
Date: Mon, 19 Sep 2016 15:29:53 +0200
From: Georg Sauthoff <mail@...rg.so>
To: musl@...ts.openwall.com
Subject: Re: memchr() performance

On Sun, Sep 18, 2016 at 10:40:36PM +0200, Szabolcs Nagy wrote:

Hello,

> * Georg Sauthoff <mail@...rg.so> [2016-09-18 20:54:22 +0200]:

[..]

> > On recent Intel CPUs it is even slower than a naive implementation:
> > 
> > https://gms.tf/stdfind-and-memchr-optimizations.html#measurements
> > https://gms.tf/sparc-and-ppc-find-benchmark-results.html
> > 
> > Of course, on x86, other implementations that use SIMD instructions
> > perform even better.

> yes simd is expected to be faster.
 
> but that needs asm which is expensive to maintain (there is no
> portable simd language extension for c and there is the aliasing
> issue: the reinterpret_cast in your code is formally ub).

you mean because the vector-word pointer returned by reinterpret_cast is
used to access vector-words in the memory passed via a char pointer and
this is not covered by the ISO C++ strict aliasing rules?

Yes. Sure, ub means that anything can happen, but this case should be ok
with GCC - if the function is compiled in isolation in its own
translation unit.

I mean, there isn't much possibiltiy for reordering due to the
application of strict-aliasing-rules that would yield a different
result.

There are no aliased write accesses.

Btw, the current musl memchr() implementation has similar aliased
accesses - there, unsigned characters are aliased via a size_t pointer. 

Best regards
Georg

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.