On Fri, Nov 24, 2017 at 10:18 AM, Marc Glisse <marc.gli...@inria.fr> wrote:
> On Thu, 23 Nov 2017, Richard Biener wrote:
>
>> What about 0 - ptr?  (ok, that's even more weird)
>
>
>         * match.pd (0-ptr): New transformation.
>
> Regtested on gcc112.

Ok.

Thanks,
Richard.

> --
> Marc Glisse
> Index: gcc/match.pd
> ===================================================================
> --- gcc/match.pd        (revision 255118)
> +++ gcc/match.pd        (working copy)
> @@ -2449,23 +2449,27 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>      (minus @0 { tem; })))))
>
>  /* Convert x+x into x*2.  */
>  (simplify
>   (plus @0 @0)
>   (if (SCALAR_FLOAT_TYPE_P (type))
>    (mult @0 { build_real (type, dconst2); })
>    (if (INTEGRAL_TYPE_P (type))
>     (mult @0 { build_int_cst (type, 2); }))))
>
> +/* 0 - X  ->  -X.  */
>  (simplify
>   (minus integer_zerop @1)
>   (negate @1))
> +(simplify
> + (pointer_diff integer_zerop @1)
> + (negate (convert @1)))
>
>  /* (ARG0 - ARG1) is the same as (-ARG1 + ARG0).  So check whether
>     ARG0 is zero and X + ARG0 reduces to X, since that would mean
>     (-ARG1 + ARG0) reduces to -ARG1.  */
>  (simplify
>   (minus real_zerop@0 @1)
>   (if (fold_real_zero_addition_p (type, @0, 0))
>    (negate @1)))
>
>  /* Transform x * -1 into -x.  */
>

Reply via email to