This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Should gcc-4.0 apply mathematical associative rules for addition or multiplication
On Oct 4, 2004, at 7:35 PM, Gabriel Dos Reis wrote:
| associative_tree_code also returns true for MIN_EXPR/MAX_EXPR. I
think
| we want to only
| exclude PLUS_EXPR/MULT_EXPR.
and all additive expressions (e.g. MINUS_EXPR) and multiplicative
expressions (include division).
-- Gaby
I am testing the following patch. This patch disallows folding of
MULT_EXPR/PLUS_EXPR
with floating operands. Only such illegal operations which can happen
in the fall-thru block of
code.
- fariborz
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.56
diff -c -p -r2.56 tree-ssa-dom.c
*** tree-ssa-dom.c 29 Sep 2004 02:50:46 -0000 2.56
--- tree-ssa-dom.c 5 Oct 2004 15:04:43 -0000
*************** simplify_rhs_and_lookup_avail_expr (stru
*** 1606,1612 ****
tree rhs_def_rhs = TREE_OPERAND (rhs_def_stmt, 1);
enum tree_code rhs_def_code = TREE_CODE (rhs_def_rhs);
! if (rhs_code == rhs_def_code
|| (rhs_code == PLUS_EXPR && rhs_def_code == MINUS_EXPR)
|| (rhs_code == MINUS_EXPR && rhs_def_code == PLUS_EXPR))
{
--- 1606,1615 ----
tree rhs_def_rhs = TREE_OPERAND (rhs_def_stmt, 1);
enum tree_code rhs_def_code = TREE_CODE (rhs_def_rhs);
! if ((rhs_code == rhs_def_code
! && !(!flag_unsafe_math_optimizations
! && (rhs_code == MULT_EXPR || rhs_code == PLUS_EXPR)
! && FLOAT_TYPE_P (TREE_TYPE (rhs))))
|| (rhs_code == PLUS_EXPR && rhs_def_code == MINUS_EXPR)
|| (rhs_code == MINUS_EXPR && rhs_def_code == PLUS_EXPR))
{