[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 wilco at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED CC||wilco at gcc dot gnu.org Resolution|--- |FIXED --- Comment #6 from wilco at gcc dot gnu.org --- Fixed in r240568.
[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 --- Comment #5 from Oleg Endo --- https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=240568
[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 --- Comment #4 from Andrew Pinski --- See bug 32650 also.
[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 Andrew Pinski changed: What|Removed |Added Keywords||missed-optimization Severity|normal |enhancement
[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 --- Comment #3 from Oleg Endo --- Just for reference https://gcc.gnu.org/ml/gcc-patches/2016-04/msg00870.html
[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 --- (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?
[Bug tree-optimization/61056] strchr (x, 0) is not converted to strlen (x)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61056 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- 1) your testcase uses strrchr rather than strchr 2) why do you think it is desirable to convert strchr (x, 0) to x + strlen (x)? 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).