This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tuples] remove valid_gimple_expression_p and {set,get}_rhs


Guys, are you ok with this?

Given binary operands for an expression that is already gimple, will
fold_binary ever muff it up into something not gimple?  Somehow I doubt
it, since we're using fold* on gimple operands and sticking them back
into a tuple in other optimization passes.

Besides, it looks like GVN is the only one really dependent on this
behavior valid_gimple_expression_p business.

If you guys are ok with this, I'd like to commit.

Aldy

	* tree-ssa-sccvn.c (valueize_expr): Update comment.
	(simplify_binary_expression): Remove call to
	valid_gimple_expression_p.
	(simplify_unary_expression): Same.
	* tree-ssa-propagate.c (get_rhs): Remove.
	(valid_gimple_expression_p): Remove.
	(set_rhs): Remove.
	* tree-ssa-propagate.h: Remove get_rhs, valid_gimple_expression_p, and
	set_rhs.

Index: tree-ssa-sccvn.c
===================================================================
--- tree-ssa-sccvn.c	(revision 137555)
+++ tree-ssa-sccvn.c	(working copy)
@@ -1720,7 +1720,7 @@ valueize_expr (tree expr)
   return expr;
 }
 
-/* Simplify the binary expression RHS, and return the result if
+/* Simplify the binary expression on the RHS of STMT, and return the result if
    simplified. */
 
 static tree
@@ -1760,20 +1760,19 @@ simplify_binary_expression (gimple stmt)
   result = fold_binary (gimple_assign_rhs_code (stmt),
 			TREE_TYPE (gimple_get_lhs (stmt)), op0, op1);
 
-  fold_undefer_overflow_warnings (result && valid_gimple_expression_p (result),
-				  stmt, 0);
+  fold_undefer_overflow_warnings (result != NULL_TREE, stmt, 0);
 
   /* Make sure result is not a complex expression consisting
      of operators of operators (IE (a + b) + (a + c))
      Otherwise, we will end up with unbounded expressions if
      fold does anything at all.  */
-  if (result && valid_gimple_expression_p (result))
+  if (result != NULL_TREE)
     return result;
 
   return NULL_TREE;
 }
 
-/* Simplify the unary expression RHS, and return the result if
+/* Simplify the unary expression on the RHS of STMT, and return the result if
    simplified. */
 
 static tree
@@ -1812,14 +1811,13 @@ simplify_unary_expression (gimple stmt)
   if (result)
     {
       STRIP_USELESS_TYPE_CONVERSION (result);
-      if (valid_gimple_expression_p (result))
-        return result;
+      return result;
     }
 
   return NULL_TREE;
 }
 
-/* Try to simplify RHS using equivalences and constant folding.  */
+/* Try to simplify the RHS of STMT using equivalences and constant folding.  */
 
 static tree
 try_to_simplify (gimple stmt)
Index: tree-ssa-propagate.c
===================================================================
--- tree-ssa-propagate.c	(revision 137555)
+++ tree-ssa-propagate.c	(working copy)
@@ -542,166 +542,6 @@ ssa_prop_fini (void)
 }
 
 
-/* Get the main expression from statement STMT.  */
-
-tree
-get_rhs (gimple stmt ATTRIBUTE_UNUSED)
-{
-  fprintf (stderr, "get_rhs() is no longer valid.\n");
-
-  /* FIXME tuples.  */
-#if 0
-  switch (code)
-    {
-    case RETURN_EXPR:
-      stmt = TREE_OPERAND (stmt, 0);
-      if (!stmt || TREE_CODE (stmt) != GIMPLE_MODIFY_STMT)
-	return stmt;
-      /* FALLTHRU */
-
-    case GIMPLE_MODIFY_STMT:
-      stmt = GENERIC_TREE_OPERAND (stmt, 1);
-      if (TREE_CODE (stmt) == WITH_SIZE_EXPR)
-	return TREE_OPERAND (stmt, 0);
-      else
-	return stmt;
-
-    case COND_EXPR:
-      return COND_EXPR_COND (stmt);
-    case SWITCH_EXPR:
-      return SWITCH_COND (stmt);
-    case GOTO_EXPR:
-      return GOTO_DESTINATION (stmt);
-    case LABEL_EXPR:
-      return LABEL_EXPR_LABEL (stmt);
-
-    default:
-      return stmt;
-    }
-#else
-  gimple_unreachable ();
-  return NULL;
-#endif
-}
-
-
-/* FIXME tuples.  Remove this.  */
-/* Return true if EXPR is a valid GIMPLE expression.  */
-
-bool
-valid_gimple_expression_p (tree expr ATTRIBUTE_UNUSED)
-{
-  gimple_unreachable ();
-  return false;
-}
-
-
-/* Set the main expression of *STMT_P to EXPR.  If EXPR is not a valid
-   GIMPLE expression no changes are done and the function returns
-   false.  */
-
-bool
-set_rhs (gimple *stmt_p ATTRIBUTE_UNUSED, tree expr ATTRIBUTE_UNUSED)
-{
-  fprintf (stderr, "set_rhs() is no longer valid.\n");
-
-  /* FIXME tuples.  */
-#if 0
-  tree stmt = *stmt_p, op;
-  tree new_stmt;
-  tree var;
-  ssa_op_iter iter;
-  int eh_region;
-
-  if (!valid_gimple_expression_p (expr))
-    return false;
-
-  if (EXPR_HAS_LOCATION (stmt)
-      && (EXPR_P (expr)
-	  || GIMPLE_STMT_P (expr))
-      && ! EXPR_HAS_LOCATION (expr)
-      && TREE_SIDE_EFFECTS (expr)
-      && TREE_CODE (expr) != LABEL_EXPR)
-    SET_EXPR_LOCATION (expr, EXPR_LOCATION (stmt));
-
-  switch (TREE_CODE (stmt))
-    {
-    case RETURN_EXPR:
-      op = TREE_OPERAND (stmt, 0);
-      if (TREE_CODE (op) != GIMPLE_MODIFY_STMT)
-	{
-	  GIMPLE_STMT_OPERAND (stmt, 0) = expr;
-	  break;
-	}
-      stmt = op;
-      /* FALLTHRU */
-
-    case GIMPLE_MODIFY_STMT:
-      op = GIMPLE_STMT_OPERAND (stmt, 1);
-      if (TREE_CODE (op) == WITH_SIZE_EXPR)
-	TREE_OPERAND (op, 0) = expr;
-      else
-	GIMPLE_STMT_OPERAND (stmt, 1) = expr;
-      break;
-
-    case COND_EXPR:
-      if (!is_gimple_condexpr (expr))
-        return false;
-      COND_EXPR_COND (stmt) = expr;
-      break;
-    case SWITCH_EXPR:
-      SWITCH_COND (stmt) = expr;
-      break;
-    case GOTO_EXPR:
-      GOTO_DESTINATION (stmt) = expr;
-      break;
-    case LABEL_EXPR:
-      LABEL_EXPR_LABEL (stmt) = expr;
-      break;
-
-    default:
-      /* Replace the whole statement with EXPR.  If EXPR has no side
-	 effects, then replace *STMT_P with an empty statement.  */
-      new_stmt = TREE_SIDE_EFFECTS (expr) ? expr : build_empty_stmt ();
-      *stmt_p = new_stmt;
-
-      /* Preserve the annotation, the histograms and the EH region information
-         associated with the original statement. The EH information
-	 needs to be preserved only if the new statement still can throw.  */
-      new_stmt->base.ann = (tree_ann_t) stmt_ann (stmt);
-      gimple_move_stmt_histograms (cfun, new_stmt, stmt);
-      if (tree_could_throw_p (new_stmt))
-	{
-	  eh_region = lookup_stmt_eh_region (stmt);
-	  /* We couldn't possibly turn a nothrow into a throw statement.  */
-	  gcc_assert (eh_region >= 0);
-	  remove_stmt_from_eh_region (stmt);
-	  add_stmt_to_eh_region (new_stmt, eh_region);
-	}
-
-      if (gimple_in_ssa_p (cfun)
-	  && TREE_SIDE_EFFECTS (expr))
-	{
-	  /* Fix all the SSA_NAMEs created by *STMT_P to point to its new
-	     replacement.  */
-	  FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_DEFS)
-	    {
-	      if (TREE_CODE (var) == SSA_NAME)
-		SSA_NAME_DEF_STMT (var) = *stmt_p;
-	    }
-	}
-      stmt->base.ann = NULL;
-      break;
-    }
-
-  return true;
-#else
-  gimple_unreachable ();
-  return false;
-#endif
-}
-
-
 /* Return true if EXPR is an acceptable right-hand-side for a
    GIMPLE assignment.  We validate the entire tree, not just
    the root node, thus catching expressions that embed complex
Index: tree-ssa-propagate.h
===================================================================
--- tree-ssa-propagate.h	(revision 137555)
+++ tree-ssa-propagate.h	(working copy)
@@ -124,9 +124,6 @@ typedef enum ssa_prop_result (*ssa_prop_
 
 /* In tree-ssa-propagate.c  */
 void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn);
-tree get_rhs (gimple);				/* FIXME tuples.  Depecrate.  */
-bool valid_gimple_expression_p (tree expr);	/* FIXME tuples.  Depecrate.  */
-bool set_rhs (gimple *, tree);			/* FIXME tuples.  Depecrate.  */
 bool valid_gimple_rhs_p (tree);
 bool valid_gimple_call_p (tree);
 void move_ssa_defining_stmt_for_defs (gimple, gimple);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]