]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/34825 (ICE with -funsafe-math-optimizations)
authorRichard Guenther <rguenther@suse.de>
Thu, 17 Jan 2008 12:17:24 +0000 (12:17 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 17 Jan 2008 12:17:24 +0000 (12:17 +0000)
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: r131595

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

index 309c57f39ed02c3b28637eec5ad57b8bdd304222..1700242050894243a010bd661535f0c5b8579ee6 100644 (file)
@@ -1,3 +1,9 @@
+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-01-16  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * pa64-hpux.h (LIB_SPEC): Add "-lpthread" in shared links if "-mt" or
index f732e1d4cd03a7698266f1eef73c89ce61dc0785..a4a95462c037f671ffa17dcd4ce3711e1897a536 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-17  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/34825
+       * gcc.dg/pr34825.c: New testcase.
+
 2008-01-17  Richard Guenther  <rguenther@suse.de>
 
        * gcc.c-torture/execute/20080117-1.c: New testcase.
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 543169ad932598ea44910aece6d30d7c929e752e..5a7bf8bc66dd839a097a0649efa00f429ded692c 100644 (file)
@@ -275,7 +275,11 @@ is_division_by (tree use_stmt, tree def)
 {
   return TREE_CODE (use_stmt) == GIMPLE_MODIFY_STMT
         && TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == RDIV_EXPR
-        && TREE_OPERAND (GIMPLE_STMT_OPERAND (use_stmt, 1), 1) == def;
+        && TREE_OPERAND (GIMPLE_STMT_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 (GIMPLE_STMT_OPERAND (use_stmt, 1), 0) != def;
 }
 
 /* Walk the subset of the dominator tree rooted at OCC, setting the