This is the mail archive of the
mailing list for the GCC project.
Re: help with PR78809 - inline strcmp for small constant strings
- From: Richard Henderson <rth at twiddle dot net>
- To: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, Richard Henderson <richard dot henderson at linaro dot org>, Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: nd <nd at arm dot com>
- Date: Fri, 4 Aug 2017 14:03:48 -0700
- Subject: Re: help with PR78809 - inline strcmp for small constant strings
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjM=6ZNhfqUCnF4fhr18hen=ZKpO3wTGh2WAvqK+cY0uPsw@mail.gmail.com> <email@example.com> <DB6PR0801MB205327474C52E6FCA824262E83B60@DB6PR0801MB2053.eurprd08.prod.outlook.com>
On 08/04/2017 01:38 PM, Wilco Dijkstra wrote:
>> For constant strings of small length (upto 3?), I was wondering if it'd be a
>> good idea to manually unroll strcmp loop, similar to __strcmp_* macros in
>> For eg in gimple-fold, transform
>> x = __builtin_strcmp(s, "ab")
>> x = s - 'a';
>> if (x == 0)
>> x = s - 'b';
>> if (x == 0)
>> x = s;
> If there is already code that does something similar (see comment #1 in PR78809),
> it could be easily adapted to handle more cases.
There's emit_block_cmp_hints and compare_by_pieces.
There is not anything at present that will do the above
such that we avoid extra loads.
> Even better would be wider loads if you either know the alignment
> of s or it's max size (although given the overhead of creating the
> return value that works best for equality).
It looks like compare_by_pieces does that.