From: Richard Guenther Date: Thu, 17 Jan 2008 12:17:24 +0000 (+0000) Subject: re PR tree-optimization/34825 (ICE with -funsafe-math-optimizations) X-Git-Tag: releases/gcc-4.3.0~573 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a5b57cdfd40c2996c755d4cc2707c5ea3c2ca67;p=thirdparty%2Fgcc.git re PR tree-optimization/34825 (ICE with -funsafe-math-optimizations) 2008-01-17 Richard Guenther 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 309c57f39ed0..170024205089 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-01-17 Richard Guenther + + 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 * pa64-hpux.h (LIB_SPEC): Add "-lpthread" in shared links if "-mt" or diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f732e1d4cd03..a4a95462c037 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-01-17 Richard Guenther + + PR tree-optimization/34825 + * gcc.dg/pr34825.c: New testcase. + 2008-01-17 Richard Guenther * 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 index 000000000000..40061bad6b53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr34825.c @@ -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; +} + diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 543169ad9325..5a7bf8bc66dd 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -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