From: Richard Guenther Date: Thu, 17 Apr 2008 09:09:31 +0000 (+0000) Subject: tree-vn.c (expressions_equal_p): Do not check type equality or compatibility before... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba2e189251286ceb6830a36bbbf44d20bda1e29a;p=gcc.git tree-vn.c (expressions_equal_p): Do not check type equality or compatibility before calling operand_equal_p. 2008-04-17 Richard Guenther * tree-vn.c (expressions_equal_p): Do not check type equality or compatibility before calling operand_equal_p. * fold-const.c (operand_equal_p): Check equivalence of integer constants before bailing out due to signedness or precision differences. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Ignore spurious differences in type qualification. Ignore types for COMPONENT_REFs at all. * gcc.dg/tree-ssa/ssa-fre-17.c: New testcase. From-SVN: r134384 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4efd1c0ecc2..4a3a4d0bd53 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2008-04-17 Richard Guenther + + * tree-vn.c (expressions_equal_p): Do not check type + equality or compatibility before calling operand_equal_p. + * fold-const.c (operand_equal_p): Check equivalence of + integer constants before bailing out due to signedness or + precision differences. + * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Ignore + spurious differences in type qualification. Ignore types + for COMPONENT_REFs at all. + 2008-04-17 Christian Bruel * config/sh/sh.c (expand_cbranchdi4): Use original operands for diff --git a/gcc/fold-const.c b/gcc/fold-const.c index c1451789af0..4e467615dd1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -3026,6 +3026,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) if (TREE_CODE (arg0) == ERROR_MARK || TREE_CODE (arg1) == ERROR_MARK) return 0; + /* Check equality of integer constants before bailing out due to + precision differences. */ + if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) + return tree_int_cst_equal (arg0, arg1); + /* If both types don't have the same signedness, then we can't consider them equal. We must check this before the STRIP_NOPS calls because they may change the signedness of the arguments. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 88c24ec7f3d..3723bcf7392 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-04-17 Richard Guenther + + * gcc.dg/tree-ssa/ssa-fre-17.c: New testcase. + 2008-04-17 Christian Bruel * gcc.dg/long-long-compare-1.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-17.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-17.c new file mode 100644 index 00000000000..aced64977ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-17.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre-details -fno-tree-sra" } */ + +struct Bar { + int dom; +}; +struct Foo { + struct Bar doms[3]; +}; + +int foo(int i, int j, int k) +{ + struct Foo f; + + f.doms[0].dom = i; + f.doms[1].dom = j; + f.doms[2].dom = k; + return f.doms[0LL].dom; +} + +/* { dg-final { scan-tree-dump "Replaced f.doms\\\[0\\\].dom with i_" "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ + diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 849eade1d21..6fc0840150f 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -511,7 +511,8 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) vn_reference_op_s temp; memset (&temp, 0, sizeof (temp)); - temp.type = TREE_TYPE (ref); + /* We do not care for spurious type qualifications. */ + temp.type = TYPE_MAIN_VARIANT (TREE_TYPE (ref)); temp.opcode = TREE_CODE (ref); switch (temp.opcode) @@ -528,6 +529,10 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) temp.op1 = TREE_OPERAND (ref, 2); break; case COMPONENT_REF: + /* The field decl is enough to unambiguously specify the field, + a matching type is not necessary and a mismatching type + is always a spurious difference. */ + temp.type = NULL_TREE; /* If this is a reference to a union member, record the union member size as operand. Do so only if we are doing expression insertion (during FRE), as PRE currently gets @@ -536,10 +541,7 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) && TREE_CODE (DECL_CONTEXT (TREE_OPERAND (ref, 1))) == UNION_TYPE && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (ref, 1))) && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (ref, 1)))) - { - temp.type = NULL_TREE; - temp.op0 = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1))); - } + temp.op0 = TYPE_SIZE (TREE_TYPE (TREE_OPERAND (ref, 1))); else /* Record field as operand. */ temp.op0 = TREE_OPERAND (ref, 1); diff --git a/gcc/tree-vn.c b/gcc/tree-vn.c index c09dfb76284..40efea6f8f7 100644 --- a/gcc/tree-vn.c +++ b/gcc/tree-vn.c @@ -83,8 +83,6 @@ expressions_equal_p (tree e1, tree e2) } else if (TREE_CODE (e1) == TREE_CODE (e2) - && (te1 == te2 - || types_compatible_p (te1, te2)) && operand_equal_p (e1, e2, OEP_PURE_SAME)) return true;