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] minor cleanups


This patch removes some unused code, removes some fixmes, and factors
out some common code to remove yet another fixme.

I've removed the fixme in mudflap because I only found 4-5 instances of
creating trees and immediately gimplifying them, and they weren't any
worse than the rest of the passes.

Tested on x86-64 Linux.

	* tree-ssa-propagate.c (valid_gimple_expression_p): Remove.
	* tree-ssa-propagate.h (valid_gimple_expression_p): Remove.
	* tree-eh.c: Factor out common code in operation_could_trap_p and 
	stmt_could_throw_1_p into...
	(operation_could_trap_helper_p): New.
	* gimplify.c (gimplify_expr): Rephrase fixme.
	* tree-mudflap.c: Remove fixme.

Index: tree-ssa-propagate.c
===================================================================
--- tree-ssa-propagate.c	(revision 137917)
+++ tree-ssa-propagate.c	(working copy)
@@ -543,17 +543,6 @@ ssa_prop_fini (void)
 }
 
 
-/* FIXME tuples.  Remove this.  */
-/* Return true if EXPR is a valid GIMPLE expression.  */
-
-bool
-valid_gimple_expression_p (tree expr ATTRIBUTE_UNUSED)
-{
-  gcc_unreachable ();
-  return false;
-}
-
-
 /* 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 137917)
+++ tree-ssa-propagate.h	(working copy)
@@ -124,7 +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);
-bool valid_gimple_expression_p (tree expr);	/* 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: tree-eh.c
===================================================================
--- tree-eh.c	(revision 137917)
+++ tree-eh.c	(working copy)
@@ -2063,24 +2063,18 @@ verify_eh_edges (gimple stmt)
 }
 
 
-/* Return true if operation OP may trap.  FP_OPERATION is true if OP is applied
-   on floating-point values.  HONOR_TRAPV is true if OP is applied on integer
-   type operands that may trap.  If OP is a division operator, DIVISOR contains
-   the value of the divisor.  */
+/* Helper function for operation_could_trap_p and stmt_could_throw_p.  */
 
-bool
-operation_could_trap_p (enum tree_code op, bool fp_operation, bool honor_trapv,
-			tree divisor)
+static bool
+operation_could_trap_helper_p (enum tree_code op,
+			       bool fp_operation,
+			       bool honor_trapv,
+			       bool honor_nans,
+			       bool honor_snans,
+			       tree divisor,
+			       bool *handled)
 {
-  bool honor_nans = (fp_operation && flag_trapping_math
-		     && !flag_finite_math_only);
-  bool honor_snans = fp_operation && flag_signaling_nans != 0;
-
-  if (TREE_CODE_CLASS (op) != tcc_comparison
-      && TREE_CODE_CLASS (op) != tcc_unary
-      && TREE_CODE_CLASS (op) != tcc_binary)
-    return false;
-
+  *handled = true;
   switch (op)
     {
     case TRUNC_DIV_EXPR:
@@ -2148,10 +2142,35 @@ operation_could_trap_p (enum tree_code o
       if (fp_operation && flag_trapping_math)
 	return true;
 
+      *handled = false;
       return false;
     }
 }
 
+/* Return true if operation OP may trap.  FP_OPERATION is true if OP is applied
+   on floating-point values.  HONOR_TRAPV is true if OP is applied on integer
+   type operands that may trap.  If OP is a division operator, DIVISOR contains
+   the value of the divisor.  */
+
+bool
+operation_could_trap_p (enum tree_code op, bool fp_operation, bool honor_trapv,
+			tree divisor)
+{
+  bool honor_nans = (fp_operation && flag_trapping_math
+		     && !flag_finite_math_only);
+  bool honor_snans = fp_operation && flag_signaling_nans != 0;
+  bool handled;
+
+  if (TREE_CODE_CLASS (op) != tcc_comparison
+      && TREE_CODE_CLASS (op) != tcc_unary
+      && TREE_CODE_CLASS (op) != tcc_binary)
+    return false;
+
+  return operation_could_trap_helper_p (op, fp_operation, honor_trapv,
+					honor_nans, honor_snans, divisor,
+					&handled);
+}
+
 /* Return true if EXPR can trap, as in dereferencing an invalid pointer
    location or floating point arithmetic.  C.f. the rtl version, may_trap_p.
    This routine expects only GIMPLE lhs or rhs input.  */
@@ -2247,9 +2266,7 @@ tree_could_trap_p (tree expr)
 
 
 /* Helper for stmt_could_throw_p.  Return true if STMT (assumed to be a
-   an assignment or a conditional) may throw.  FIXME tuples, this is
-   very similar to tree_could_trap_p but only works with GIMPLE
-   operands.  Try to factor out common code.  */
+   an assignment or a conditional) may throw.  */
 
 static bool
 stmt_could_throw_1_p (gimple stmt)
@@ -2261,6 +2278,7 @@ stmt_could_throw_1_p (gimple stmt)
   bool honor_trapv = false;
   tree t;
   size_t i;
+  bool handled, ret;
 
   if (TREE_CODE_CLASS (code) == tcc_comparison
       || TREE_CODE_CLASS (code) == tcc_unary
@@ -2278,74 +2296,12 @@ stmt_could_throw_1_p (gimple stmt)
     }
 
   /* Check if the main expression may trap.  */
-  switch (code)
-    {
-    case TRUNC_DIV_EXPR:
-    case CEIL_DIV_EXPR:
-    case FLOOR_DIV_EXPR:
-    case ROUND_DIV_EXPR:
-    case EXACT_DIV_EXPR:
-    case CEIL_MOD_EXPR:
-    case FLOOR_MOD_EXPR:
-    case ROUND_MOD_EXPR:
-    case TRUNC_MOD_EXPR:
-    case RDIV_EXPR:
-      if (honor_snans || honor_trapv)
-	return true;
-      if (fp_operation)
-	return flag_trapping_math;
-      t = gimple_assign_rhs2 (stmt);
-      if (!TREE_CONSTANT (t) || integer_zerop (t))
-	return true;
-      return false;
-
-    case LT_EXPR:
-    case LE_EXPR:
-    case GT_EXPR:
-    case GE_EXPR:
-    case LTGT_EXPR:
-      /* Some floating point comparisons may trap.  */
-      return honor_nans;
-
-    case EQ_EXPR:
-    case NE_EXPR:
-    case UNORDERED_EXPR:
-    case ORDERED_EXPR:
-    case UNLT_EXPR:
-    case UNLE_EXPR:
-    case UNGT_EXPR:
-    case UNGE_EXPR:
-    case UNEQ_EXPR:
-      return honor_snans;
-
-    case CONVERT_EXPR:
-    case FIX_TRUNC_EXPR:
-      /* Conversion of floating point might trap.  */
-      return honor_nans;
-
-    case NEGATE_EXPR:
-    case ABS_EXPR:
-    case CONJ_EXPR:
-      /* These operations don't trap with floating point.  */
-      if (honor_trapv)
-	return true;
-      return false;
-
-    case PLUS_EXPR:
-    case MINUS_EXPR:
-    case MULT_EXPR:
-      /* Any floating arithmetic may trap.  */
-      if (fp_operation && flag_trapping_math)
-	return true;
-      if (honor_trapv)
-	return true;
-      return false;
-
-    default:
-      /* Any floating arithmetic may trap.  */
-      if (fp_operation && flag_trapping_math)
-	return true;
-    }
+  t = is_gimple_assign (stmt) ? gimple_assign_rhs2 (stmt) : NULL;
+  ret = operation_could_trap_helper_p (code, fp_operation, honor_trapv,
+				       honor_nans, honor_snans, t,
+				       &handled);
+  if (handled)
+    return ret;
 
   /* If the expression does not trap, see if any of the individual operands may
      trap.  */
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 137917)
+++ gimplify.c	(working copy)
@@ -6042,7 +6042,7 @@ gimplify_omp_atomic (tree *expr_p, gimpl
    emitted in PRE_P and POST_P.
 
    Additionally, this process may overwrite parts of the input
-   expression during gimplification.  FIXME tuples, it should be
+   expression during gimplification.  Ideally, it should be
    possible to do non-destructive gimplification.
 
    EXPR_P points to the GENERIC expression to convert to GIMPLE.  If
Index: tree-mudflap.c
===================================================================
--- tree-mudflap.c	(revision 137917)
+++ tree-mudflap.c	(working copy)
@@ -47,11 +47,6 @@ along with GCC; see the file COPYING3.  
 #include "toplev.h"
 #include "gimple.h"
 
-/* FIXME-tuples: This file has been tuplified enough to work but there
-   is still a bit of tree-based code here.  We construct temporary
-   trees in few places and then call gimplify_expr to get equivalent
-   gimples.  These can be done directly with gimple builders.  */
-
 /* Internal function decls */
 
 


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