This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize strlen comparisons against zero
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: [PATCH] Optimize strlen comparisons against zero
- From: Roger Sayle <roger at eyesopen dot com>
- Date: Sat, 3 Nov 2001 13:39:18 -0700 (MST)
- cc: <gcc-patches at gcc dot gnu dot org>
>> 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
--