+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.
(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
+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.
--- /dev/null
+/* { 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" } } */
/* { 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)
{
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));