summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-14 00:10:42 +0000
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-14 00:10:42 +0000
commitb527c406657ea65992c795ce5800a0646cde8810 (patch)
tree374322382bce0dcc52445ff4261931542fd1ecae /gcc
parentba09ff60163bac27faab82e5279db330f5e67656 (diff)
downloadgcc-b527c406657ea65992c795ce5800a0646cde8810.tar.gz
Handle GIMPLE_ASSIGNs with different vuse in gimple_equal_p
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. * gcc.dg/tail-merge-store.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204767 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/tail-merge-store.c22
-rw-r--r--gcc/tree-ssa-tail-merge.c13
4 files changed, 42 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 66d9c7b2e5e..dad20a4bdb5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
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.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 93080a8d0b8..ddbb62eeb07 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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.
diff --git a/gcc/testsuite/gcc.dg/tail-merge-store.c b/gcc/testsuite/gcc.dg/tail-merge-store.c
new file mode 100644
index 00000000000..1aefbdc1495
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tail-merge-store.c
@@ -0,0 +1,22 @@
+/* { 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" } } */
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index ca69b23e4bb..c97da97f6d3 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1142,8 +1142,17 @@ gimple_equal_p (same_succ same_succ, gimple s1, gimple s2)
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);