Similar to the previous patches: remove the strict_overflow_p flag to
allow us to remove the fold_overflow_warn() from the parent function
tree_single_nonnegative_warnv_p.

The changes done in fold-const.cc caused a ripple effect on
gimple-fold.cc, where we ended up doing similar changes to
gimple_assign_nonnegative_warnv_p and gimple_phi_nonnegative_warnv_p.

gcc/ChangeLog:

        * fold-const.cc (tree_single_nonnegative_warnv_p): Renamed to
        tree_single_nonnegative_p.
        (tree_single_nonnegative_p): Removed strict_overflow_p flag.
        (tree_expr_nonnegative_warnv_p): Removed strict_overflow_p flag
        from tree_single_nonnegative_p call.
        * fold-const.h (tree_single_nonnegative_warnv_p): Renamed to
        tree_single_nonnegative_p.
        (tree_single_nonnegative_p): Removed strict_overflow_p flag.
        * gimple-fold.cc (gimple_assign_nonnegative_warnv_p): Renamed to
        gimple_assign_nonnegative_p.
        (gimple_assign_nonnegative_p): Removed strict_overflow_p flag.
        (gimple_phi_nonnegative_warnv_p): Renamed to
        gimple_phi_nonnegative_p.
        (gimple_phi_nonnegative_p): Removed strict_overflow_p flag.
        (gimple_stmt_nonnegative_warnv_p): Removed strict_overflow_p
        flag from gimple_phi_nonnegative_p and gimple_assign_nonnegative_p
        calls.
---
 gcc/fold-const.cc  | 17 ++++++++++-------
 gcc/fold-const.h   |  2 +-
 gcc/gimple-fold.cc | 26 +++++++++-----------------
 3 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index bd5d8e5a12f..550e1574425 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -14783,17 +14783,20 @@ tree_binary_nonnegative_p (enum tree_code code, tree 
type, tree op0,
   return false;
 }
 
-/* Return true if T is known to be non-negative.  If the return
-   value is based on the assumption that signed overflow is undefined,
-   set *STRICT_OVERFLOW_P to true; otherwise, don't change
-   *STRICT_OVERFLOW_P.  DEPTH is the current nesting depth of the query.  */
+/* Return true if T is known to be non-negative.
+   DEPTH is the current nesting depth of the query.  */
 
 bool
-tree_single_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
+tree_single_nonnegative_p (tree t, int depth)
 {
   if (TYPE_UNSIGNED (TREE_TYPE (t)))
     return true;
 
+  /* The RECURSE () macro counts with a strict_overflow_p bool
+     pointer being declared beforehand.  */
+  bool val = false;
+  bool *strict_overflow_p = &val;
+
   switch (TREE_CODE (t))
     {
     case INTEGER_CST:
@@ -15116,7 +15119,7 @@ tree_expr_nonnegative_warnv_p (tree t, bool 
*strict_overflow_p, int depth)
     case tcc_constant:
     case tcc_declaration:
     case tcc_reference:
-      return tree_single_nonnegative_warnv_p (t, strict_overflow_p, depth);
+      return tree_single_nonnegative_p (t, depth);
 
     default:
       break;
@@ -15144,7 +15147,7 @@ tree_expr_nonnegative_warnv_p (tree t, bool 
*strict_overflow_p, int depth)
     case ADDR_EXPR:
     case WITH_SIZE_EXPR:
     case SSA_NAME:
-      return tree_single_nonnegative_warnv_p (t, strict_overflow_p, depth);
+      return tree_single_nonnegative_p (t, depth);
 
     default:
       return tree_invalid_nonnegative_warnv_p (t, strict_overflow_p, depth);
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 8f5d5b69982..bc2d619e3d7 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -167,7 +167,7 @@ extern bool tree_binary_nonzero_p (enum tree_code, tree, 
tree, tree op1);
 extern bool tree_single_nonzero_p (tree);
 extern bool tree_unary_nonnegative_p (enum tree_code, tree, tree, int);
 extern bool tree_binary_nonnegative_p (enum tree_code, tree, tree, tree, int);
-extern bool tree_single_nonnegative_warnv_p (tree, bool *, int);
+extern bool tree_single_nonnegative_p (tree, int);
 extern bool tree_call_nonnegative_warnv_p (tree, combined_fn, tree, tree,
                                           bool *, int);
 
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 333802f4482..e022099ab4c 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -11389,13 +11389,10 @@ gimple_build_round_up (gimple_stmt_iterator *gsi,
 }
 
 /* Return true if the result of assignment STMT is known to be non-negative.
-   If the return value is based on the assumption that signed overflow is
-   undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change
-   *STRICT_OVERFLOW_P.  DEPTH is the current nesting depth of the query.  */
+   DEPTH is the current nesting depth of the query.  */
 
 static bool
-gimple_assign_nonnegative_warnv_p (gimple *stmt, bool *strict_overflow_p,
-                                  int depth)
+gimple_assign_nonnegative_p (gimple *stmt, int depth)
 {
   enum tree_code code = gimple_assign_rhs_code (stmt);
   tree type = TREE_TYPE (gimple_assign_lhs (stmt));
@@ -11415,8 +11412,8 @@ gimple_assign_nonnegative_warnv_p (gimple *stmt, bool 
*strict_overflow_p,
     case GIMPLE_TERNARY_RHS:
       return false;
     case GIMPLE_SINGLE_RHS:
-      return tree_single_nonnegative_warnv_p (gimple_assign_rhs1 (stmt),
-                                             strict_overflow_p, depth);
+      return tree_single_nonnegative_p (gimple_assign_rhs1 (stmt),
+                                       depth);
     case GIMPLE_INVALID_RHS:
       break;
     }
@@ -11445,18 +11442,15 @@ gimple_call_nonnegative_warnv_p (gimple *stmt, bool 
*strict_overflow_p,
 }
 
 /* Return true if return value of call STMT is known to be non-negative.
-   If the return value is based on the assumption that signed overflow is
-   undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change
-   *STRICT_OVERFLOW_P.  DEPTH is the current nesting depth of the query.  */
+   DEPTH is the current nesting depth of the query.  */
 
 static bool
-gimple_phi_nonnegative_warnv_p (gimple *stmt, bool *strict_overflow_p,
-                               int depth)
+gimple_phi_nonnegative_p (gimple *stmt, int depth)
 {
   for (unsigned i = 0; i < gimple_phi_num_args (stmt); ++i)
     {
       tree arg = gimple_phi_arg_def (stmt, i);
-      if (!tree_single_nonnegative_warnv_p (arg, strict_overflow_p, depth + 1))
+      if (!tree_single_nonnegative_p (arg, depth + 1))
        return false;
     }
   return true;
@@ -11483,14 +11477,12 @@ gimple_stmt_nonnegative_warnv_p (gimple *stmt, bool 
*strict_overflow_p,
   switch (gimple_code (stmt))
     {
     case GIMPLE_ASSIGN:
-      return gimple_assign_nonnegative_warnv_p (stmt, strict_overflow_p,
-                                               depth);
+      return gimple_assign_nonnegative_p (stmt, depth);
     case GIMPLE_CALL:
       return gimple_call_nonnegative_warnv_p (stmt, strict_overflow_p,
                                              depth);
     case GIMPLE_PHI:
-      return gimple_phi_nonnegative_warnv_p (stmt, strict_overflow_p,
-                                            depth);
+      return gimple_phi_nonnegative_p (stmt, depth);
     default:
       return false;
     }
-- 
2.43.0

Reply via email to