re PR middle-end/55152 (MAX_EXPR(a,-a) is really ABS_EXPR(a))

2016-10-05  Richard Biener  <rguenther@suse.de>

	PR middle-end/55152
	* match.pd (min(a,-a) -> -abs(a)): New pattern.

	* gcc.dg/pr55152-2.c: New testcase.

From-SVN: r240770
This commit is contained in:
Richard Biener 2016-10-05 07:48:24 +00:00 committed by Richard Biener
parent 17beda50fb
commit 54f84ca9c7
4 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2016-10-05 Richard Biener <rguenther@suse.de>
PR middle-end/55152
* match.pd (min(a,-a) -> -abs(a)): New pattern.
2016-10-04 Ian Lance Taylor <iant@golang.org>
* explow.c (allocate_dynamic_stack_space): Call

View File

@ -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

View File

@ -1,3 +1,8 @@
2016-10-05 Richard Biener <rguenther@suse.de>
PR middle-end/55152
* gcc.dg/pr55152-2.c: New testcase.
2016-10-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* gfortran.dg/dtio_15.f90: New test.

View File

@ -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" } } */