From: Richard Biener Date: Mon, 8 Jan 2018 08:16:19 +0000 (+0000) Subject: re PR tree-optimization/83517 (Missed optimization in math expression: (x+x)/x == 2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55d84e61f3e929af53e1c29321c5fc031f071d13;p=gcc.git 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 --- 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" } } */