From 406520e26f53e3c38118886f79b9e3f7e355e978 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 24 Nov 2017 13:09:14 +0100 Subject: [PATCH] Simplify 0 - ptr. 2017-11-24 Marc Glisse * match.pd (0-ptr): New transformation. From-SVN: r255139 --- gcc/ChangeLog | 4 ++++ gcc/match.pd | 4 ++++ 2 files changed, 8 insertions(+) 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 -- 2.30.2