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]

Re: [PATCH] Optimize strlen comparisons against zero



>> Isn't just one strcpy enough?
>
> I was worried that CSE may eventually realize that strlen is a const
> function, and just re-use the same value of a single evaluation of
> strlen(ptr) in all of the tests

Opps.  I've now consulted the GCC documentation and the phrase that
I was looking for is that strlen is a "pure" function and not a
"const" function.  The GCC manual even lists strlen and memcmp as
examples of pure functions.  Either these builtins are not being
marked pure or the optimizer is unable to take advantage of it in
my previous example.

Roger
--


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