https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81657

--- Comment #17 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #16)
> (In reply to Wilco from comment #15)
> > I don't think it's safe to compare different benchmark results like that.
> > But yes the kernel for both should be very similar. The key difference is
> > that strchr needs 2x the number of comparisons, which is why an optimized
> > strlen will always be faster than strchr.
> 
> That is of course not true, it can do e.g. just the number of comparisons
> strlen needs + 1.

No, strchr searches for 2 characters, strlen for just 1. Of course if you want
to special case strchr (p, 0) to use strlen because that is faster then I guess
we agree that is the right transformation.

Reply via email to