+2010-01-21 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/19988
+ * fold-const.c (negate_expr_p): Pretend only negative
+ real constants are easily negatable.
+
2010-01-20 Janis Johnson <janis187@us.ibm.com>
Jason Merrill <jason@redhat.com>
&& TYPE_OVERFLOW_WRAPS (type));
case FIXED_CST:
- case REAL_CST:
case NEGATE_EXPR:
return true;
+ case REAL_CST:
+ /* We want to canonicalize to positive real constants. Pretend
+ that only negative ones can be easily negated. */
+ return REAL_VALUE_NEGATIVE (TREE_REAL_CST (t));
+
case COMPLEX_CST:
return negate_expr_p (TREE_REALPART (t))
&& negate_expr_p (TREE_IMAGPART (t));
+2010-01-21 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/19988
+ * gcc.dg/pr19988.c: New testcase.
+
2010-01-20 Janis Johnson <janis187@us.ibm.com>
* g++.dg/compat/decimal/compat-common.h: New file.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized -fdump-tree-original" } */
+
+double foo(double x, double y)
+{
+ return ((x + 0.1234 * y) * (x - 0.1234 * y));
+}
+
+/* Keep positive constants during folding. */
+/* { dg-final { scan-tree-dump-times " 1.23" 2 "original" } } */
+/* CSE one multiplication. */
+/* { dg-final { scan-tree-dump-times " \\\* " 2 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */