diff mbox

[gimple-classes,committed,30/44] gimple-walk.c: Use gassign

Message ID 1415284340-14186-31-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm Nov. 6, 2014, 2:32 p.m. UTC
gcc/ChangeLog.gimple-classes:
	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN,
	introduce local gassign * "assign_stmt" and use it in place of
	"stmt" for typesafety.
---
 gcc/ChangeLog.gimple-classes |  6 ++++
 gcc/gimple-walk.c            | 74 +++++++++++++++++++++++---------------------
 2 files changed, 45 insertions(+), 35 deletions(-)
diff mbox

Patch

diff --git a/gcc/ChangeLog.gimple-classes b/gcc/ChangeLog.gimple-classes
index 9b455c3..8e18adc 100644
--- a/gcc/ChangeLog.gimple-classes
+++ b/gcc/ChangeLog.gimple-classes
@@ -1,5 +1,11 @@ 
 2014-11-03  David Malcolm  <dmalcolm@redhat.com>
 
+	* gimple-walk.c (walk_gimple_op): Within case GIMPLE_ASSIGN,
+	introduce local gassign * "assign_stmt" and use it in place of
+	"stmt" for typesafety.
+
+2014-11-03  David Malcolm  <dmalcolm@redhat.com>
+
 	* tree-ssa-dse.c (dse_optimize_stmt): Add checked cast.  Replace
 	is_gimple_assign with dyn_cast, introducing local gassign *
 	"assign_stmt", using it in place of "stmt" for typesafety.
diff --git a/gcc/gimple-walk.c b/gcc/gimple-walk.c
index 9a800e2..d74e66a 100644
--- a/gcc/gimple-walk.c
+++ b/gcc/gimple-walk.c
@@ -195,46 +195,50 @@  walk_gimple_op (gimple stmt, walk_tree_fn callback_op,
   switch (gimple_code (stmt))
     {
     case GIMPLE_ASSIGN:
-      /* Walk the RHS operands.  If the LHS is of a non-renamable type or
-         is a register variable, we may use a COMPONENT_REF on the RHS.  */
-      if (wi)
-	{
-	  tree lhs = gimple_assign_lhs (stmt);
-	  wi->val_only
-	    = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
-	      || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
-	}
+      {
+	gassign *assign_stmt = as_a <gassign *> (stmt);
 
-      for (i = 1; i < gimple_num_ops (stmt); i++)
-	{
-	  ret = walk_tree (gimple_op_ptr (stmt, i), callback_op, wi,
-			   pset);
-	  if (ret)
-	    return ret;
-	}
+	/* Walk the RHS operands.  If the LHS is of a non-renamable type or
+	   is a register variable, we may use a COMPONENT_REF on the RHS.  */
+	if (wi)
+	  {
+	    tree lhs = gimple_assign_lhs (assign_stmt);
+	    wi->val_only
+	      = (is_gimple_reg_type (TREE_TYPE (lhs)) && !is_gimple_reg (lhs))
+		|| gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS;
+	  }
 
-      /* Walk the LHS.  If the RHS is appropriate for a memory, we
-	 may use a COMPONENT_REF on the LHS.  */
-      if (wi)
-	{
-          /* If the RHS is of a non-renamable type or is a register variable,
-	     we may use a COMPONENT_REF on the LHS.  */
-	  tree rhs1 = gimple_assign_rhs1 (stmt);
-	  wi->val_only
-	    = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
-	      || gimple_assign_rhs_class (stmt) != GIMPLE_SINGLE_RHS;
-	  wi->is_lhs = true;
+	for (i = 1; i < gimple_num_ops (assign_stmt); i++)
+	  {
+	    ret = walk_tree (gimple_op_ptr (assign_stmt, i), callback_op, wi,
+			     pset);
+	    if (ret)
+	      return ret;
+	  }
+
+	/* Walk the LHS.  If the RHS is appropriate for a memory, we
+	   may use a COMPONENT_REF on the LHS.  */
+	if (wi)
+	  {
+	    /* If the RHS is of a non-renamable type or is a register variable,
+	       we may use a COMPONENT_REF on the LHS.  */
+	    tree rhs1 = gimple_assign_rhs1 (assign_stmt);
+	    wi->val_only
+	      = (is_gimple_reg_type (TREE_TYPE (rhs1)) && !is_gimple_reg (rhs1))
+		|| gimple_assign_rhs_class (assign_stmt) != GIMPLE_SINGLE_RHS;
+	    wi->is_lhs = true;
 	}
 
-      ret = walk_tree (gimple_op_ptr (stmt, 0), callback_op, wi, pset);
-      if (ret)
-	return ret;
+	ret = walk_tree (gimple_op_ptr (assign_stmt, 0), callback_op, wi, pset);
+	if (ret)
+	  return ret;
 
-      if (wi)
-	{
-	  wi->val_only = true;
-	  wi->is_lhs = false;
-	}
+	if (wi)
+	  {
+	    wi->val_only = true;
+	    wi->is_lhs = false;
+	  }
+      }
       break;
 
     case GIMPLE_CALL: