tree-vn.c (expressions_equal_p): Do not check type equality or compatibility before calling operand_equal_p.

2008-04-17  Richard Guenther  <rguenther@suse.de>

	* 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
This commit is contained in:
Richard Guenther 2008-04-17 09:09:31 +00:00 committed by Richard Biener
parent 499928c154
commit ba2e189251
6 changed files with 50 additions and 7 deletions

View File

@ -1,3 +1,14 @@
2008-04-17 Richard Guenther <rguenther@suse.de>
* 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 <christian.bruel@st.com>
* config/sh/sh.c (expand_cbranchdi4): Use original operands for

View File

@ -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. */

View File

@ -1,3 +1,7 @@
2008-04-17 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-fre-17.c: New testcase.
2008-04-17 Christian Bruel <christian.bruel@st.com>
* gcc.dg/long-long-compare-1.c: New testcase.

View File

@ -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" } } */

View File

@ -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);

View File

@ -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;