tree-flow.h (vrp_evaluate_conditional): Change signature.
authorRafael Avila de Espindola <espindola@google.com>
Thu, 24 Apr 2008 09:48:41 +0000 (09:48 +0000)
committerRafael Espindola <espindola@gcc.gnu.org>
Thu, 24 Apr 2008 09:48:41 +0000 (09:48 +0000)
2008-04-24  Rafael Espindola  <espindola@google.com>

* tree-flow.h (vrp_evaluate_conditional): Change signature.
* tree-ssa-propagate.c (fold_predicate_in): Update call to
vrp_evaluate_conditional.
* tree-vrp.c (vrp_evaluate_conditional_warnv): Remove.
        (vrp_evaluate_conditional): Split the cond argument.
        (vrp_visit_cond_stmt): Use vrp_evaluate_conditional_warnv_with_ops.
        (simplify_stmt_for_jump_threading): Update call to
vrp_evaluate_conditional.

From-SVN: r134625

gcc/ChangeLog
gcc/tree-flow.h
gcc/tree-ssa-propagate.c
gcc/tree-vrp.c

index b567b495cdc68abb6b4cb9be087f558f29fb13b2..3bd5e7f6cc4807a9aee094e9b2617bc6ecce257e 100644 (file)
@@ -1,3 +1,14 @@
+2008-04-24  Rafael Espindola  <espindola@google.com>
+
+       * tree-flow.h (vrp_evaluate_conditional): Change signature.
+       * tree-ssa-propagate.c (fold_predicate_in): Update call to
+       vrp_evaluate_conditional.
+       * tree-vrp.c (vrp_evaluate_conditional_warnv): Remove.
+        (vrp_evaluate_conditional): Split the cond argument.
+        (vrp_visit_cond_stmt): Use vrp_evaluate_conditional_warnv_with_ops.
+        (simplify_stmt_for_jump_threading): Update call to
+       vrp_evaluate_conditional.
+
 2008-04-24  Ira Rosen  <irar@il.ibm.com>
 
        PR tree-optimization/35982
index 03d1ba5ee5d490c00453f3f4be19362cb501f509..f26181fb9e1dc1a5d84835351fb6bc48e58b86fe 100644 (file)
@@ -944,7 +944,7 @@ tree get_symbol_constant_value (tree);
 tree fold_const_aggregate_ref (tree);
 
 /* In tree-vrp.c  */
-tree vrp_evaluate_conditional (tree, tree);
+tree vrp_evaluate_conditional (enum tree_code, tree, tree, tree);
 void simplify_stmt_using_ranges (tree);
 
 /* In tree-ssa-dom.c  */
index c37cfa53545b07a2523c9c5ff2f8f4a6c29d8c5b..6423ec6ba524b979143ff19bd95082eae0baa876 100644 (file)
@@ -1148,7 +1148,17 @@ fold_predicate_in (tree stmt)
   else
     return false;
 
-  val = vrp_evaluate_conditional (*pred_p, stmt);
+  if (TREE_CODE (*pred_p) == SSA_NAME)
+    val = vrp_evaluate_conditional (EQ_EXPR,
+                                   *pred_p,
+                                   boolean_true_node,
+                                   stmt);
+  else
+    val = vrp_evaluate_conditional (TREE_CODE (*pred_p),
+                                   TREE_OPERAND (*pred_p, 0),
+                                   TREE_OPERAND (*pred_p, 1),
+                                   stmt);
+
   if (val)
     {
       if (modify_stmt_p)
index 95f2a5238da354ce61ebd334600e4747ca1a84ed..f65a3c397c83c1294557d9cde7dc53e1569816d7 100644 (file)
@@ -46,7 +46,6 @@ static sbitmap found_in_subgraph;
 static int compare_values (tree val1, tree val2);
 static int compare_values_warnv (tree val1, tree val2, bool *);
 static void vrp_meet (value_range_t *, value_range_t *);
-static tree vrp_evaluate_conditional_warnv (tree, bool, bool *);
 static tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
                                                     tree, tree, bool, bool *);
 
@@ -5272,64 +5271,7 @@ vrp_evaluate_conditional_warnv_with_ops (enum tree_code code, tree op0,
   return NULL_TREE;
 }
 
-/* Given a conditional predicate COND, try to determine if COND yields
-   true or false based on the value ranges of its operands.  Return
-   BOOLEAN_TRUE_NODE if the conditional always evaluates to true,
-   BOOLEAN_FALSE_NODE if the conditional always evaluates to false, and,
-   NULL if the conditional cannot be evaluated at compile time.
-
-   If USE_EQUIV_P is true, the ranges of all the names equivalent with
-   the operands in COND are used when trying to compute its value.
-   This is only used during final substitution.  During propagation,
-   we only check the range of each variable and not its equivalents.
-
-   Set *STRICT_OVERFLOW_P to indicate whether we relied on an overflow
-   infinity to produce the result.  */
-
-static tree
-vrp_evaluate_conditional_warnv (tree cond, bool use_equiv_p,
-                               bool *strict_overflow_p)
-{
-  gcc_assert (TREE_CODE (cond) == SSA_NAME
-              || TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison);
-
-  if (TREE_CODE (cond) == SSA_NAME)
-    {
-      value_range_t *vr;
-      tree retval;
-
-      if (use_equiv_p)
-       retval = compare_name_with_value (NE_EXPR, cond, boolean_false_node,
-                                         strict_overflow_p);
-      else
-       {
-         value_range_t *vr = get_value_range (cond);
-         retval = compare_range_with_value (NE_EXPR, vr, boolean_false_node,
-                                            strict_overflow_p);
-       }
-
-      /* If COND has a known boolean range, return it.  */
-      if (retval)
-       return retval;
-
-      /* Otherwise, if COND has a symbolic range of exactly one value,
-        return it.  */
-      vr = get_value_range (cond);
-      if (vr->type == VR_RANGE && vr->min == vr->max)
-       return vr->min;
-    }
-  else
-    return vrp_evaluate_conditional_warnv_with_ops (TREE_CODE (cond),
-                                                   TREE_OPERAND (cond, 0),
-                                                   TREE_OPERAND (cond, 1),
-                                                   use_equiv_p,
-                                                   strict_overflow_p);
-
-  /* Anything else cannot be computed statically.  */
-  return NULL_TREE;
-}
-
-/* Given COND within STMT, try to simplify it based on value range
+/* Given (CODE OP0 OP1) within STMT, try to simplify it based on value range
    information.  Return NULL if the conditional can not be evaluated.
    The ranges of all the names equivalent with the operands in COND
    will be used when trying to compute the value.  If the result is
@@ -5337,13 +5279,17 @@ vrp_evaluate_conditional_warnv (tree cond, bool use_equiv_p,
    appropriate.  */
 
 tree
-vrp_evaluate_conditional (tree cond, tree stmt)
+vrp_evaluate_conditional (enum tree_code code, tree op0, tree op1, tree stmt)
 {
   bool sop;
   tree ret;
 
   sop = false;
-  ret = vrp_evaluate_conditional_warnv (cond, true, &sop);
+  ret = vrp_evaluate_conditional_warnv_with_ops (code,
+                                                op0,
+                                                op1,
+                                                true,
+                                                &sop);
 
   if (ret && sop)
     {
@@ -5377,8 +5323,8 @@ vrp_evaluate_conditional (tree cond, tree stmt)
 
   if (warn_type_limits
       && ret
-      && TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison
-      && TREE_CODE (TREE_OPERAND (cond, 0)) == SSA_NAME)
+      && TREE_CODE_CLASS (code) == tcc_comparison
+      && TREE_CODE (op0) == SSA_NAME)
     {
       /* If the comparison is being folded and the operand on the LHS
         is being compared against a constant value that is outside of
@@ -5386,8 +5332,6 @@ vrp_evaluate_conditional (tree cond, tree stmt)
         always fold regardless of the value of OP0.  If -Wtype-limits
         was specified, emit a warning.  */
       const char *warnmsg = NULL;
-      tree op0 = TREE_OPERAND (cond, 0);
-      tree op1 = TREE_OPERAND (cond, 1);
       tree type = TREE_TYPE (op0);
       value_range_t *vr0 = get_value_range (op0);
 
@@ -5499,7 +5443,19 @@ vrp_visit_cond_stmt (tree stmt, edge *taken_edge_p)
      MICO, TRAMP3D and SPEC2000) showed that doing this results in
      4 more predicates folded in SPEC.  */
   sop = false;
-  val = vrp_evaluate_conditional_warnv (cond, false, &sop);
+
+  if (TREE_CODE (cond) == SSA_NAME)
+    val = vrp_evaluate_conditional_warnv_with_ops (EQ_EXPR,
+                                                  cond,
+                                                  boolean_true_node,
+                                                  false,
+                                                  &sop);
+  else
+    val = vrp_evaluate_conditional_warnv_with_ops (TREE_CODE (cond),
+                                                  TREE_OPERAND (cond, 0),
+                                                  TREE_OPERAND (cond, 1),
+                                                  false,
+                                                  &sop);
   if (val)
     {
       if (!sop)
@@ -6470,13 +6426,24 @@ static VEC(tree,heap) *stack;
 static tree
 simplify_stmt_for_jump_threading (tree stmt, tree within_stmt)
 {
+  tree conditional;
   /* We only use VRP information to simplify conditionals.  This is
      overly conservative, but it's unclear if doing more would be
      worth the compile time cost.  */
   if (TREE_CODE (stmt) != COND_EXPR)
     return NULL;
 
-  return vrp_evaluate_conditional (COND_EXPR_COND (stmt), within_stmt);
+  conditional = COND_EXPR_COND (stmt);
+  if (TREE_CODE (conditional) == SSA_NAME)
+    return vrp_evaluate_conditional (EQ_EXPR,
+                                    conditional,
+                                    boolean_true_node,
+                                    within_stmt);
+  else
+    return vrp_evaluate_conditional (TREE_CODE (conditional),
+                                    TREE_OPERAND (conditional, 0),
+                                    TREE_OPERAND (conditional, 1),
+                                    within_stmt);
 }
 
 /* Blocks which have more than one predecessor and more than