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

2016-09-29  Richard Biener  <rguenther@suse.de>

	PR middle-end/55152
	* match.pd: Add max(a,-a) -> abs(a) pattern.
	* tree-ssa-phiopt.c (minmax_replacement): Disable for
	HONOR_SIGNED_ZEROS types.

	* gcc.dg/pr55152.c: New testcase.
	* gcc.dg/tree-ssa/phi-opt-5.c: Adjust.

From-SVN: r240615
This commit is contained in:
Richard Biener 2016-09-29 12:27:19 +00:00 committed by Richard Biener
parent 75304c8793
commit d657e99522
6 changed files with 35 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2016-09-29 Richard Biener <rguenther@suse.de>
PR middle-end/55152
* match.pd: Add max(a,-a) -> abs(a) pattern.
* tree-ssa-phiopt.c (minmax_replacement): Disable for
HONOR_SIGNED_ZEROS types.
2016-09-29 James Greenhalgh <james.greenhalgh@arm.com>
* defaults.h (TARGET_FLT_EVAL_METHOD_NON_DEFAULT): Remove.

View file

@ -1271,6 +1271,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(simplify
(max:c (min:c @0 @1) @1)
@1)
/* max(a,-a) -> abs(a). */
(simplify
(max:c @0 (negate @0))
(if (TREE_CODE (type) != COMPLEX_TYPE
&& (! ANY_INTEGRAL_TYPE_P (type)
|| TYPE_OVERFLOW_UNDEFINED (type)))
(abs @0)))
(simplify
(min @0 @1)
(switch

View file

@ -1,3 +1,9 @@
2016-09-29 Richard Biener <rguenther@suse.de>
PR middle-end/55152
* gcc.dg/pr55152.c: New testcase.
* gcc.dg/tree-ssa/phi-opt-5.c: Adjust.
2016-09-29 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gcc.dg/profile-update-warning.c: Restrict to ia32.

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

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O1 -ffinite-math-only -fdump-tree-phiopt1" } */
/* { dg-options "-O1 -ffinite-math-only -fno-signed-zeros -fdump-tree-phiopt1" } */
float repl1 (float varx)
{

View file

@ -1075,7 +1075,7 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
type = TREE_TYPE (PHI_RESULT (phi));
/* The optimization may be unsafe due to NaNs. */
if (HONOR_NANS (type))
if (HONOR_NANS (type) || HONOR_SIGNED_ZEROS (type))
return false;
cond = as_a <gcond *> (last_stmt (cond_bb));