From: Richard Biener Date: Wed, 5 Oct 2016 07:48:24 +0000 (+0000) Subject: re PR middle-end/55152 (MAX_EXPR(a,-a) is really ABS_EXPR(a)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=54f84ca9c7a1955f9760df4c2df72be9272e0db3;p=gcc.git re PR middle-end/55152 (MAX_EXPR(a,-a) is really ABS_EXPR(a)) 2016-10-05 Richard Biener PR middle-end/55152 * match.pd (min(a,-a) -> -abs(a)): New pattern. * gcc.dg/pr55152-2.c: New testcase. From-SVN: r240770 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ad08f0f771f..a65f491b3ee 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-10-05 Richard Biener + + PR middle-end/55152 + * match.pd (min(a,-a) -> -abs(a)): New pattern. + 2016-10-04 Ian Lance Taylor * explow.c (allocate_dynamic_stack_space): Call diff --git a/gcc/match.pd b/gcc/match.pd index dadf51cd205..067e66788cf 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1291,6 +1291,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && (! ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type))) (abs @0))) +/* min(a,-a) -> -abs(a). */ +(simplify + (min:c @0 (negate @0)) + (if (TREE_CODE (type) != COMPLEX_TYPE + && (! ANY_INTEGRAL_TYPE_P (type) + || TYPE_OVERFLOW_UNDEFINED (type))) + (negate (abs @0)))) (simplify (min @0 @1) (switch diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41186f84162..e77ed889553 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-10-05 Richard Biener + + PR middle-end/55152 + * gcc.dg/pr55152-2.c: New testcase. + 2016-10-04 Jerry DeLisle * gfortran.dg/dtio_15.f90: New test. diff --git a/gcc/testsuite/gcc.dg/pr55152-2.c b/gcc/testsuite/gcc.dg/pr55152-2.c new file mode 100644 index 00000000000..54db0f2062d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr55152-2.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ffinite-math-only -fno-signed-zeros -fstrict-overflow -fdump-tree-optimized" } */ + +double g (double a) +{ + return (a<-a)?a:-a; +} +int f(int a) +{ + return (a<-a)?a:-a; +} + +/* { dg-final { scan-tree-dump-times "ABS_EXPR" 2 "optimized" } } */