]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/34825 (ICE with -funsafe-math-optimizations)
authorRichard Guenther <rguenther@suse.de>
Tue, 5 Feb 2008 12:31:50 +0000 (12:31 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 5 Feb 2008 12:31:50 +0000 (12:31 +0000)
2008-05-02  Richard Guenther  <rguenther@suse.de>

        Backport from mainline:
        2008-01-17  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/34825
        * tree-ssa-math-opts.c (is_division_by): Do not recognize
        x / x as division to handle.

        * gcc.dg/pr34825.c: New testcase.

From-SVN: r132119

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr34825.c [new file with mode: 0644]
gcc/tree-ssa-math-opts.c

index fb6472fb909595452b83da045aaea0f856d0fc07..9d1b6ae34e646854833339573b19fc9e4b3bce2c 100644 (file)
@@ -1,3 +1,12 @@
+2008-02-05  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       2008-01-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/34825
+       * tree-ssa-math-opts.c (is_division_by): Do not recognize
+       x / x as division to handle.
+
 2008-02-05  Joseph Myers  <joseph@codesourcery.com>
 
        * doc/include/texinfo.tex: Update to version 2008-02-04.16.
index feda984adaf998288ef3ad9b84bc6d5a1fa080eb..07cffc5a2ba3e10c7639a40d4ab20b4e26d04430 100644 (file)
@@ -1,3 +1,11 @@
+2008-02-05  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline:
+       2008-01-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/34825
+       * gcc.dg/pr34825.c: New testcase.
+
 2008-02-05  Richard Guenther  <rguenther@suse.de>
 
        Backport from mainline:
diff --git a/gcc/testsuite/gcc.dg/pr34825.c b/gcc/testsuite/gcc.dg/pr34825.c
new file mode 100644 (file)
index 0000000..40061ba
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O -funsafe-math-optimizations" } */
+
+double foo(double x, double y)
+{
+  return x == y ? x/y*x/y : 0;
+}
+
index c3942ed65537eb19524f67392c086cdfa2d88907..5ce3a544ae77dc1ea95c34a8f25124e695d7c3e9 100644 (file)
@@ -275,7 +275,11 @@ is_division_by (tree use_stmt, tree def)
 {
   return TREE_CODE (use_stmt) == MODIFY_EXPR
         && TREE_CODE (TREE_OPERAND (use_stmt, 1)) == RDIV_EXPR
-        && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def;
+        && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def
+        /* Do not recognize x / x as valid division, as we are getting
+           confused later by replacing all immediate uses x in such
+           a stmt.  */
+        && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 0) != def;
 }
 
 /* Walk the subset of the dominator tree rooted at OCC, setting the