aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2008-02-20 14:14:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2008-02-20 14:14:55 +0000
commit41bb1f06d37ed77ec4b4f88034ac7c16f81f07be (patch)
tree4f3c12af6c8a7f71b6cb1c2536dd5f7815b793ff /gcc
parent2dc0f63301e9bddc5520f2a283d7a8bfdac21fb6 (diff)
downloadgcc-41bb1f06d37ed77ec4b4f88034ac7c16f81f07be.zip
gcc-41bb1f06d37ed77ec4b4f88034ac7c16f81f07be.tar.gz
gcc-41bb1f06d37ed77ec4b4f88034ac7c16f81f07be.tar.bz2
fold-const.c (split_tree): Associate floatig-point expressions if flag_associative_math is set.
2008-02-20 Richard Guenther <rguenther@suse.de> * fold-const.c (split_tree): Associate floatig-point expressions if flag_associative_math is set. * gcc.dg/fold-reassoc-1.c: New testcase. * gcc.dg/tree-ssa/recip-3.c: Adjust to not compute d/d. From-SVN: r132481
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/fold-reassoc-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/recip-3.c2
5 files changed, 22 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 18dd9dc..91bd7e2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2008-02-20 Richard Guenther <rguenther@suse.de>
+ * fold-const.c (split_tree): Associate floatig-point expressions
+ if flag_associative_math is set.
+
+2008-02-20 Richard Guenther <rguenther@suse.de>
+
* tree.h (fold_real_zero_addition_p): Declare.
* fold-const.c (fold_real_zero_addition_p): Export.
* tree-ssa-reassoc.c (eliminate_using_constants): Also handle
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index aba71b6..5d64c17 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1491,7 +1491,7 @@ split_tree (tree in, enum tree_code code, tree *conp, tree *litp,
|| TREE_CODE (in) == FIXED_CST)
*litp = in;
else if (TREE_CODE (in) == code
- || (! FLOAT_TYPE_P (TREE_TYPE (in))
+ || ((! FLOAT_TYPE_P (TREE_TYPE (in)) || flag_associative_math)
&& ! SAT_FIXED_POINT_TYPE_P (TREE_TYPE (in))
/* We can associate addition and subtraction together (even
though the C standard doesn't say so) for integers because
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7e947ec..8b9fb37 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2008-02-20 Richard Guenther <rguenther@suse.de>
+ * gcc.dg/fold-reassoc-1.c: New testcase.
+ * gcc.dg/tree-ssa/recip-3.c: Adjust to not compute d/d.
+
+2008-02-20 Richard Guenther <rguenther@suse.de>
+
* gcc.dg/tree-ssa/reassoc-13.c: New testcase.
2008-02-20 Ira Rosen <irar@il.ibm.com>
diff --git a/gcc/testsuite/gcc.dg/fold-reassoc-1.c b/gcc/testsuite/gcc.dg/fold-reassoc-1.c
new file mode 100644
index 0000000..88d5dd8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-reassoc-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ffast-math -fdump-tree-original" } */
+
+double foo (double x)
+{
+ return (x + 0.5 - x - 0.5);
+}
+
+/* { dg-final { scan-tree-dump "return 0.0;" "original" } } */
+/* { dg-final { cleanup-tree-dump "original" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/recip-3.c b/gcc/testsuite/gcc.dg/tree-ssa/recip-3.c
index 45c8db1..04b40f3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/recip-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/recip-3.c
@@ -9,7 +9,7 @@ float h ()
int i;
double E, W, P, d;
- W = 1.;
+ W = 1.1;
d = 2.*e;
E = 1. - d;