From: Marc Glisse Date: Fri, 24 Nov 2017 12:09:14 +0000 (+0100) Subject: Simplify 0 - ptr. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=406520e26f53e3c38118886f79b9e3f7e355e978;p=gcc.git Simplify 0 - ptr. 2017-11-24 Marc Glisse * match.pd (0-ptr): New transformation. From-SVN: r255139 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 92b355a73df..b866e2512a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-11-24 Marc Glisse + + * match.pd (0-ptr): New transformation. + 2017-11-24 Jan Hubicka PR bootstrap/83015 diff --git a/gcc/match.pd b/gcc/match.pd index 84db1ee7360..9db48bda047 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2456,9 +2456,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (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