[PATCH] add VRP for bitwise OR and AND: v2

Daniel Berlin dannyb@google.com
Wed Aug 9 19:12:00 GMT 2006


Denis Vlasenko wrote:
> Thanks for all the comments.
> 
> This is the second version of the patch.
> It is against gcc-4.2-20060805.

Just some comments on the code itself for now (again, you will
eventually need a changelog before this patch can be truly reviewed, i
would suggest you submit it with the next iteration of this patch, just
to see if more people are willing to look at the code).

I'll take a look at the rest of your questions later if someone doesn'
beat me to it.


> +static int
> +integer_nonnegative_range (value_range_t *vr, tree type)
> +{
> +  if (vr->type == VR_RANGE
> +      && TREE_CODE (vr->min) == INTEGER_CST
> +      && vrp_expr_computes_nonnegative (vr->min)
> +      && TREE_CODE (vr->max) == INTEGER_CST) {
> +    return 1;
> +}
> +/* FIXME: does not compile (trips assert)
> +  if (TYPE_UNSIGNED (type))
> +    {
> +      set_value_range_to_nonnegative (vr, type);
> +      return 1;
> +    }
> +*/
> +  return 0;


Err, you should find out why it asserts.  Sounds like it should work at
first glance.

> +}
> +
> +static tree
> +TYPE_ALL_ONES_VALUE (tree type)
> +{
> +  tree result;
> +  result = vrp_int_const_binop (LSHIFT_EXPR, TYPE_MAX_VALUE(type), integer_one_node);
> +  result = vrp_int_const_binop (PLUS_EXPR, result, integer_one_node);
> +  return result;
> +}
>  


Don't give functions all capital names, use lower case. Upper case is
reserved for macros (or in some cases, inline functions that were once
macros but became functions of the same name).



More information about the Gcc-patches mailing list