[PATCH] Fold __builtin_str{n}{case}cmp functions (version 3)

Martin Liška mliska@suse.cz
Wed Oct 12 13:17:00 GMT 2016


On 10/12/2016 10:30 AM, Richard Biener wrote:
> On Tue, Oct 11, 2016 at 11:33 AM, Martin Liška <mliska@suse.cz> wrote:
>> Changes from the previous version:
>>
>> 1) Handle BUILT_IN_STRNCMP with length == -1.
>> 2) Direct gimple stmts creation and usage gsi_replace_with_seq_vops.
>> (hope using of replace_call_with_value is fine if replacing with a cst?)
> 
> yes
> 
>> 3) lhs == NULL cases are handled (Or is it fine to replace with a nop in general?
>> Can change a semantic as it may touch a memory.)
>> 4) CFN_BUILT_IN_STRNCMP can handle strncmp (x, y, 0).
>> 5) Handling of CFN_BUILT_IN_STRNCASECMP is added.
>>
>> Testing of the whole series has been running.
> 
> gimple_load_first_char needs a comment.
> 
> +      tree var = gimple_load_first_char (loc, str1, &stmts);
> +      if (lhs)
> +       stmt = gimple_build_assign (lhs, NOP_EXPR, var);
> +      else
> +       stmt = gimple_build_nop ();
> 
> I think you don't need the nop() as you have at least one stmt
> from the load.  Likewise for the other cases below.

Thanks, both nits are fixed in the new version.
Apart from that, I added usages of enhanced c_getstr API.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests
as a whole series.

Martin

> 
> Otherwise this patch looks ok now.
> 
> Richard.
> 
> 
> 
>> Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Fold-__builtin_str-n-case-cmp-functions-v4.patch
Type: text/x-patch
Size: 16083 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20161012/85f1d7fe/attachment.bin>


More information about the Gcc-patches mailing list