From 55d84e61f3e929af53e1c29321c5fc031f071d13 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 8 Jan 2018 08:16:19 +0000 Subject: [PATCH] re PR tree-optimization/83517 (Missed optimization in math expression: (x+x)/x == 2) 2018-01-08 Richard Biener PR middle-end/83517 * match.pd ((t * 2) / 2) -> t): Add missing :c. * gcc.dg/pr83517.c: New testcase. From-SVN: r256328 --- gcc/ChangeLog | 5 +++++ gcc/match.pd | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr83517.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr83517.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6fe407051a..5de2348dd21 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Richard Biener + + PR middle-end/83517 + * match.pd ((t * 2) / 2) -> t): Add missing :c. + 2018-01-06 Aldy Hernandez PR middle-end/81897 diff --git a/gcc/match.pd b/gcc/match.pd index f189cb19b41..915c20f5e12 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -510,7 +510,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Simplify (t * 2) / 2) -> t. */ (for div (trunc_div ceil_div floor_div round_div exact_div) (simplify - (div (mult @0 @1) @1) + (div (mult:c @0 @1) @1) (if (ANY_INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_UNDEFINED (type)) @0))) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 218e7821df7..9ec2e81dc56 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-01-08 Richard Biener + + PR middle-end/83517 + * gcc.dg/pr83517.c: New testcase. + 2018-01-06 Aldy Hernandez PR middle-end/81897 diff --git a/gcc/testsuite/gcc.dg/pr83517.c b/gcc/testsuite/gcc.dg/pr83517.c new file mode 100644 index 00000000000..9dadbdeddf7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83517.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ + +int test(int x) +{ + return (x+x)/x; +} + +/* { dg-final { scan-tree-dump "return 2;" "original" } } */ -- 2.30.2