This is the mail archive of the gcc-bugs@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]

[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056

--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #1)
> 1) your testcase uses strrchr rather than strchr

Sorry, typo/pasto.  It was meant to be "strchr".

> 2) why do you think it is desirable to convert strchr (x, 0) to x + strlen
> (x)?

On SH we have a builtin strlen implementation.  I was just expecting strchr (x,
0) to utilize it, that's all.

> Unless you have good library implementation for the latter and bad for the
> former, strchr (x, 0) should be a win.
> What the strlen pass does is that if you e.g. use strchr (x, 0) or strlen
> (x) several times when the lengths of the strings actually can't change in
> between, it can avoid the second and following call.  And, it is able to
> deal even with strlen (x) used in one place and strchr (x, 0) in another or
> vice versa etc. (plus various other optimizations).

Ah, thanks for the explanation.
BTW, are there any plans to add true builtin strchr support so that it can be
expanded by the target code in the same way as strlen?


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