This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize strchr (s, 0) to strlen
- From: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>, Jakub Jelinek <jakub at redhat dot com>
- Date: Tue, 13 Sep 2016 12:36:59 +0000
- Subject: Re: [PATCH] Optimize strchr (s, 0) to strlen
- Authentication-results: sourceware.org; auth=none
- Nodisclaimer: True
- References: <AM3PR08MB0088CA61259F65FAAB4D8196836B0@AM3PR08MB0088.eurprd08.prod.outlook.com> <CAFiYyc1rGd2KWOaN4RTG45Y1uUp6O0A5qOm=i5ma0BZSK5CrXw@mail.gmail.com> <AM3PR08MB00881BE3867DF3FC5B5B7530836C0@AM3PR08MB0088.eurprd08.prod.outlook.com> <CAFiYyc0cUOs19FV-2PnYxfba4_N8Qwox2tkgXZJEw2obe20zgg@mail.gmail.com> <AM3PR08MB008870D1CDEE9E149F657561836D0@AM3PR08MB0088.eurprd08.prod.outlook.com> <CAFiYyc0us3xEAbJUtwC+Gp4U6CgAjC+Gxre59PiTARf=AYfnpg@mail.gmail.com> <AM3PR08MB0088BB9EBAD6AC1489BFA9B9837B0@AM3PR08MB0088.eurprd08.prod.outlook.com> <AM3PR08MB008897E76957E408CA75B51783490@AM3PR08MB0088.eurprd08.prod.outlook.com>,<CAFiYyc2kTZDd9aPo6v-1+6ufH8x4F1FaNMcq=nDpGgnXmqwc-Q@mail.gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
Richard Biener <richard.guenther@gmail.com> wrote:
> On Wed, May 18, 2016 at 2:29 PM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>> Richard Biener wrote:
>>
>>> Yeah ;) I'm currently bootstrapping/testing the patch that makes it possible to
>>> write all this in match.pd.
>>
>> So what was the conclusion? Improving match.pd to be able to handle more cases
>> like this seems like a nice thing.
>
> I'm stuck with fallout and making this work requires some serious
> thought. Don't
> hold your breath here :/
>
> The restricted case of strchr (a, 0) -> strlen () can be made working
> more easily
> but I didn't yet try to implement a restriction only allowing the
> cases that would work.
>
> Meanwhile the strlenopt pass would be an appropriate place to handle
> this transform
> (well, if we now agree on its usefulness).
I'd like to pick this up again so we can make GCC7 a bit less inefficient for this case.
(original thread: https://gcc.gnu.org/ml/gcc-patches/2016-04/msg00870.html)
We've seen several different proposals for where/how to do this simplification, why did you
say strlenopt is best? It would be an unconditional strchr (a, 0) -> a + strlen (a) rewrite,
ie. completely unrelated to what strlenopt does. We do all the other simplifications based
on constant arguments in builtins.c and gimple-fold.c, why is strchr (s, 0) different?
Wilco