This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/3] Simplify wrapped binops


On Thu, May 18, 2017 at 3:47 PM, Robin Dapp <rdapp@linux.vnet.ibm.com> wrote:
> match.pd part of the patch.
>
> gcc/ChangeLog:
>
> 2017-05-18  Robin Dapp  <rdapp@linux.vnet.ibm.com>
>
>         * match.pd: Simplify wrapped binary operations.
>         * tree-vrp.c (extract_range_from_binary_expr_1): Add overflow
>         parameter.
>         (extract_range_from_binary_expr): Likewise.
>         * tree-vrp.h: Export.

Hi,
I didn't follow this issue from the beginning, so might asking stupid questions.

> diff --git a/gcc/match.pd b/gcc/match.pd
> index 80a17ba..3fa18b9 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -1290,6 +1290,85 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>      (if (cst && !TREE_OVERFLOW (cst))
>       (plus { cst; } @0))))
>
> +/* ((T)(A +- CST)) +- CST -> (T)(A) +- CST)  */
> +#if GIMPLE
> +   (for outer_op (plus minus)
> +     (for inner_op (plus minus)
> +       (simplify
> +     (outer_op (convert (inner_op@3 @0 INTEGER_CST@1)) INTEGER_CST@2)
> +       (if (TREE_CODE (type) == INTEGER_TYPE
> +        && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@3)))
> +        (with
> +        {
> +          bool ovf = true;
> +
> +          tree cst = NULL_TREE;
> +          tree inner_type = TREE_TYPE (@3);
> +          value_range vr = VR_INITIALIZER;
> +
> +          /* Convert combined constant to tree of outer type if
> +         there was no overflow in the original operation.  */
> +          wide_int minv, maxv;
> +          if (TYPE_OVERFLOW_UNDEFINED (inner_type)
> +          || (extract_range_from_binary_expr (&vr, inner_op,
> +            inner_type, @0, @1, &ovf), vr.type == VR_RANGE))
Any reason to expose tree-vrp.c internal interface here?  The function
looks quite expensive.  Overflow check can be done by get_range_info
and simple wi::cmp calls.  Existing code like in
tree-ssa-loop-niters.c already does that.  Also could you avoid using
comma expressions in condition please? It only makes the code harder
to be read.

Thanks,
bin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]