+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
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. */
+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.
--- /dev/null
+/* { 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" } } */
+
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)
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
&& 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);
}
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;