This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR78153
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 20 Nov 2016 19:43:54 +0530
- Subject: Re: PR78153
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMm5bQhfPjM8Ff5DrNz+zhhJqq0eTj9_r2G5AEB=LPnHHw@mail.gmail.com> <20161120140427.GV3541@tucnak.redhat.com>
On 20 November 2016 at 19:34, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sun, Nov 20, 2016 at 07:20:20PM +0530, Prathamesh Kulkarni wrote:
>> --- a/gcc/tree-vrp.c
>> +++ b/gcc/tree-vrp.c
>> @@ -4013,6 +4013,16 @@ extract_range_basic (value_range *vr, gimple *stmt)
>> : vrp_val_max (type), NULL);
>> }
>> return;
>> + case CFN_BUILT_IN_STRLEN:
>> + {
>> + tree type = TREE_TYPE (gimple_call_lhs (stmt));
>> + unsigned HOST_WIDE_INT max =
>> + TREE_INT_CST_LOW (vrp_val_max (ptrdiff_type_node)) - 1;
>
> Wrong formatting, = should go on the next line, and should be indented only
> 2 columns more than the previous line. Plus TREE_INT_CST_LOW really
> shouldn't be used in new code. You should use tree_to_uhwi or tree_to_shwi
> instead. Why the -1? Can you just
> fold_convert (type, TYPE_MAX_VALUE (ptrdiff_type_node)); ?
> Or, if you really want the -1, e.g. wide_int max = vrp_val_max (ptrdiff_type_node);
> wide_int_to_tree (type, max - 1);
> or something similar.
Hi Jakub,
Thanks for the suggestions.
Sorry I wrote misleading info in the patch. As per PR, strlen's return value
should always be less than PTRDIFF_MAX, so I am setting the range to
[0, PTRDIFF_MAX - 1].
I will use wide_int in the next version of patch.
Thanks,
Prathamesh
>> +
>> + set_value_range (vr, VR_RANGE, build_int_cst (type, 0),
>> + build_int_cst (type, max), NULL);
>> + }
>> + return;
>> default:
>> break;
>> }
>
> Jakub