Patchwork Factor out gimple_operand_equal_value_p from gimple_equal_p

login
register
mail settings
Submitter Tom de Vries
Date Nov. 9, 2013, 3:54 p.m.
Message ID <527E5ACB.60901@mentor.com>
Download mbox | patch
Permalink /patch/289998/
State New
Headers show

Comments

Tom de Vries - Nov. 9, 2013, 3:54 p.m.
Richard,

This patch factors out gimple_operand_equal_value_p from gimple_equal_p.

Bootstrapped and regtested on x86_64.

OK for trunk?

Thanks,
- Tom

2013-11-06  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.
Richard Guenther - Nov. 11, 2013, 9:37 a.m.
On Sat, 9 Nov 2013, Tom de Vries wrote:

> Richard,
> 
> This patch factors out gimple_operand_equal_value_p from gimple_equal_p.
> 
> Bootstrapped and regtested on x86_64.
> 
> OK for trunk?

Ok.

Thanks,
Richard.

> Thanks,
> - Tom
> 
> 2013-11-06  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.

Patch

diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 4223094..98b5882 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -1107,6 +1107,24 @@  gimple_dont_merge_p (gimple stmt)
   return false;
 }
 
+/* Return true if gimple operands T1 and T2 have the same value.  */
+
+static bool
+gimple_operand_equal_value_p (tree t1, tree t2)
+{
+  if (t1 == t2)
+    return true;
+
+  if (t1 == NULL_TREE
+      || t2 == NULL_TREE)
+    return false;
+
+  if (operand_equal_p (t1, t2, 0))
+    return true;
+
+  return gvn_uses_equal (t1, t2);
+}
+
 /* Return true if gimple statements S1 and S2 are equal.  Gimple_bb (s1) and
    gimple_bb (s2) are members of SAME_SUCC.  */
 
@@ -1135,9 +1153,7 @@  gimple_equal_p (same_succ same_succ, gimple s1, gimple s2)
 	{
 	  t1 = gimple_call_arg (s1, i);
 	  t2 = gimple_call_arg (s2, i);
-	  if (operand_equal_p (t1, t2, 0))
-	    continue;
-	  if (gvn_uses_equal (t1, t2))
+	  if (gimple_operand_equal_value_p (t1, t2))
 	    continue;
 	  return false;
 	}
@@ -1167,14 +1183,12 @@  gimple_equal_p (same_succ same_succ, gimple s1, gimple s2)
     case GIMPLE_COND:
       t1 = gimple_cond_lhs (s1);
       t2 = gimple_cond_lhs (s2);
-      if (!operand_equal_p (t1, t2, 0)
-	  && !gvn_uses_equal (t1, t2))
+      if (!gimple_operand_equal_value_p (t1, t2))
 	return false;
 
       t1 = gimple_cond_rhs (s1);
       t2 = gimple_cond_rhs (s2);
-      if (!operand_equal_p (t1, t2, 0)
-	  && !gvn_uses_equal (t1, t2))
+      if (!gimple_operand_equal_value_p (t1, t2))
 	return false;
 
       code1 = gimple_expr_code (s1);