diff mbox

TREE-SSA remove redundant condition checks in get_default_value

Message ID 20130812144622.09f848eb.yizhouzhou@ict.ac.cn
State New
Headers show

Commit Message

Zhouyi Zhou Aug. 12, 2013, 6:46 a.m. UTC
In function get_default_value of tree-ssa-ccp.c,
261   else if (is_gimple_assign (stmt)
262            /* Value-returning GIMPLE_CALL statements assign to
263               a variable, and are treated similarly to GIMPLE_ASSIGN.  */
264            || (is_gimple_call (stmt)
265                && gimple_call_lhs (stmt) != NULL_TREE)
266            || gimple_code (stmt) == GIMPLE_PHI)
267     {
268       tree cst;
269       if (gimple_assign_single_p (stmt)
270           && DECL_P (gimple_assign_rhs1 (stmt))
271           && (cst = get_symbol_constant_value (gimple_assign_rhs1 (stmt))))
272         {
273           val.lattice_val = CONSTANT;
274           val.value = cst;
275         }
276       else
277         /* Any other variable defined by an assignment or a PHI node
278            is considered UNDEFINED.  */
279         val.lattice_val = UNDEFINED;
if the stmt is a gimple call node or a gimple phi node, it will never satisfy
the condition gimple_assign_single_p (stmt). so there exists redundant condition
checks. The patch attached try to remove this.


Bootstrap passed. Regression tested on x86_64-unknown-linux-gnu (pc).

ChangeLog:
2013-08-13  Zhouyi Zhou  <yizhouzhou@ict.ac.cn>
	* tree-ssa-ccp.c (get_default_value): remove redundant condition checks

Comments

Jeff Law Aug. 20, 2013, 6:26 a.m. UTC | #1
On 08/12/2013 12:46 AM, Zhouyi Zhou wrote:
>
> In function get_default_value of tree-ssa-ccp.c,
> 261   else if (is_gimple_assign (stmt)
> 262            /* Value-returning GIMPLE_CALL statements assign to
> 263               a variable, and are treated similarly to GIMPLE_ASSIGN.  */
> 264            || (is_gimple_call (stmt)
> 265                && gimple_call_lhs (stmt) != NULL_TREE)
> 266            || gimple_code (stmt) == GIMPLE_PHI)
> 267     {
> 268       tree cst;
> 269       if (gimple_assign_single_p (stmt)
> 270           && DECL_P (gimple_assign_rhs1 (stmt))
> 271           && (cst = get_symbol_constant_value (gimple_assign_rhs1 (stmt))))
> 272         {
> 273           val.lattice_val = CONSTANT;
> 274           val.value = cst;
> 275         }
> 276       else
> 277         /* Any other variable defined by an assignment or a PHI node
> 278            is considered UNDEFINED.  */
> 279         val.lattice_val = UNDEFINED;
> if the stmt is a gimple call node or a gimple phi node, it will never satisfy
> the condition gimple_assign_single_p (stmt). so there exists redundant condition
> checks. The patch attached try to remove this.
>
>
> Bootstrap passed. Regression tested on x86_64-unknown-linux-gnu (pc).
>
> ChangeLog:
> 2013-08-13  Zhouyi Zhou  <yizhouzhou@ict.ac.cn>
> 	* tree-ssa-ccp.c (get_default_value): remove redundant condition checks	
Thanks.  I fixed some minor formatting issues and committed your change 
after another bootstrap & regression test.

Jeff
diff mbox

Patch

diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 6472f48..7fbb687 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -258,12 +258,7 @@  get_default_value (tree var)
 	  val.mask = double_int_minus_one;
 	}
     }
-  else if (is_gimple_assign (stmt)
-	   /* Value-returning GIMPLE_CALL statements assign to
-	      a variable, and are treated similarly to GIMPLE_ASSIGN.  */
-	   || (is_gimple_call (stmt)
-	       && gimple_call_lhs (stmt) != NULL_TREE)
-	   || gimple_code (stmt) == GIMPLE_PHI)
+  else if (is_gimple_assign (stmt))
     {
       tree cst;
       if (gimple_assign_single_p (stmt)
@@ -274,10 +269,18 @@  get_default_value (tree var)
 	  val.value = cst;
 	}
       else
-	/* Any other variable defined by an assignment or a PHI node
+	/* Any other variable defined by an assignment
 	   is considered UNDEFINED.  */
 	val.lattice_val = UNDEFINED;
     }
+  else if ((is_gimple_call (stmt)
+	       && gimple_call_lhs (stmt) != NULL_TREE)
+	   || gimple_code (stmt) == GIMPLE_PHI)
+    {
+      /*Variable defined by a call or a PHI node
+	is considered UNDEFINED. */
+      val.lattice_val = UNDEFINED;
+    }
   else
     {
       /* Otherwise, VAR will never take on a constant value.  */