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: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Cc: <nd at arm dot com>, Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 14 Sep 2016 18:04:14 +0100
- Subject: Re: [PATCH] Optimize strchr (s, 0) to strlen
- Authentication-results: sourceware.org; auth=none
- Nodisclaimer: True
- References: <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> <DB3PR08MB0089E3481502F6009D642E4283590@DB3PR08MB0089.eurprd08.prod.outlook.com> <CAFiYyc38DTZBCAsWWK-+4J_78gRx7+VCnyBDEYhhpXc7En=KPg@mail.gmail.com> <20160914134506.GR7282@tucnak.redhat.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 14/09/16 14:45, Jakub Jelinek wrote:
> I think for the middle-end, using strchr (a, 0) as canonical instead of a + strlen (a)
> is better, and at expansion time we can decide what to use (a + strlen (a)
> if you'd expand strlen inline, rather than as a function call, or
> __rawmemchr (which if libc is sane should be fastest), or strchr, or a + strlen (a)).
>
i think the compiler should move away from generating
calls to nonstandard functions, __rawmemchr is much
less used than strlen so it's less likely to be optimized
in certain target/libc combination.