2013-11-14 Tom de Vries <tom@codesourcery.com>
+ * tree-ssa-tail-merge.c (gimple_equal_p): Add test for structural
+ equality for GIMPLE_ASSIGN.
+
+2013-11-14 Tom de Vries <tom@codesourcery.com>
+
* tree-ssa-tail-merge.c (gimple_operand_equal_value_p): Factor new
function out of ...
(gimple_equal_p): ... here.
+2013-11-14 Tom de Vries <tom@codesourcery.com>
+
+ * gcc.dg/tail-merge-store.c: New test.
+
2013-11-13 Andrew MacLeod <amacleod@redhat.com>
* testsuite/g++.dg/plugin/selfassign.c: Include gimple-iterator.h.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-tail-merge -fdump-tree-pre" } */
+
+int z;
+int x;
+
+void
+f (int c, int d)
+{
+ if (c)
+ z = 5;
+ else
+ {
+ if (d)
+ x = 4;
+ z = 5;
+ }
+}
+
+/* { dg-final { scan-tree-dump-times "duplicate of" 1 "pre"} } */
+/* { dg-final { scan-tree-dump-times "z = 5" 1 "pre"} } */
+/* { dg-final { cleanup-tree-dump "pre" } } */
lhs2 = gimple_get_lhs (s2);
if (TREE_CODE (lhs1) != SSA_NAME
&& TREE_CODE (lhs2) != SSA_NAME)
- return (vn_valueize (gimple_vdef (s1))
- == vn_valueize (gimple_vdef (s2)));
+ {
+ /* If the vdef is the same, it's the same statement. */
+ if (vn_valueize (gimple_vdef (s1))
+ == vn_valueize (gimple_vdef (s2)))
+ return true;
+
+ /* Test for structural equality. */
+ return (operand_equal_p (lhs1, lhs2, 0)
+ && gimple_operand_equal_value_p (gimple_assign_rhs1 (s1),
+ gimple_assign_rhs1 (s2)));
+ }
else if (TREE_CODE (lhs1) == SSA_NAME
&& TREE_CODE (lhs2) == SSA_NAME)
return vn_valueize (lhs1) == vn_valueize (lhs2);