This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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] Optimize strchr (s, 0) to strlen


On 09/15/2016 03:38 PM, Wilco Dijkstra wrote:
__rawmemchr is not the fastest on any target I tried, including x86,

Interesting. Care to share your test program? I just looked at the libc sources and strlen/rawmemchr are practically identical code so I'd expect any difference to be lost in the noise. Of course there might be inlines interfering with the comparison.

So the only reasonable optimization is to always emit a + strlen (a).

Not sure about "only reasonable" but on the whole I'd agree that it's reasonable and we shouldn't let the perfect be the enemy of the good here. I'm sure we can come up with lots of different ways to do this but let's just pick one and if the one Wilco submitted looks decent let's just put it in.

Out of curiousity, is there real-world code that this is intended to optimize?


Bernd


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