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 strchr(x, 0), strcmp("a","b") and strstr("abc","bc")


On Tue, Nov 07, 2000 at 03:05:57PM -0500, Kaveh R. Ghazi wrote:
> 1.  How does one decide to check current_function_check_memory_usage?
> I.e. should I add it to strpbrk, esp. in light of Mark's views?

I used what I saw in expand_builtin_strcmp, basically if you don't want to
care about -fcheck-memory-usage, you can just not optimize if it is set.
> 
> 2.  I suggest constifying the return value of c_getstr().  I like the
> function BTW.

Make sense, will change this.

>  Do you recommend converting builtin strpbrk/fputs to
> use it?

If others agree, then I think they should use it (that would simplify the
code actually).
> 
> 3.  In reading your changes to builtin strstr, it looked like you
> don't fall back to strstr when the length of the second arg is greater
> than 1.  I could be wrong though.  I.e. it appears you handle arg2
> being "" and "c" right but not strstr(s1, "cd").

You're right, I should write some more tests and fix this one
(ie. add a missing if (p2[1] != '\0') return 0; ).

> 
> 4.  For strchr(s1, '\0') you convert it to strlen(s1), I think it is
> supposed to be (s1 + strlen(s1)).

Again, it is clear how proper tests are necessary (wonder why I haven't seen
anything during bootstrap/regression testing).

> 
> 5.  You should probably add a testcase for strchr(s1, '\0') as well as
> strchr with a constant s1 argument.  It'll have to be in a separate
> file from string-opt-3.c, since the transformations in that file rely
> on strchr not being a wrapper for abort.

Yes, there needs to be one string-opt-N.c test which does not have abort
wrappers for any function, plus several ones with some wrappers.

> 6.  Are you planning on adding builtin strrchr?  How about index/rindex
> like we do for bzero/bcmp?  (I.e. only when !flag_no_nonansi_builtin.)

I dunno. I will fix this patch first (perhaps with additional strrchr),
then most probably try to optimize strcmp if one argument is a short
constant string .
Thanks for you comments.

	Jakub

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