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: fold strchr (e, 0) to e + strlen (e)


On Sat, Feb 15, 2014 at 2:28 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sat, Feb 15, 2014 at 02:23:24PM +0530, Prathamesh Kulkarni wrote:
>> This patch folds strchr (e, 0) to e + strlen (e), if e has no side-effects.
>> Bootstrapped, regtested on x86_64-unknown-linux-gnu
>> Ok for trunk ?
>
> Why do you think it is a good idea?  It is often very much the opposite.
I maybe completely wrong, but since  strchr(p, 0), matches each
character of p with c until '\0' is found, I thought it would be
faster to call strlen, since strlen would just skip over characters upto '\0'.
Also, I saw this committed in llvm trunk recently, and thought it
might be a good idea:
http://llvm-reviews.chandlerc.com/rL200736

>
>         Jakub


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