https://gcc.gnu.org/g:49766e7b5df144693dc3eda40e6d86e6f1c74b65

commit r17-690-g49766e7b5df144693dc3eda40e6d86e6f1c74b65
Author: Daniel Barboza <[email protected]>
Date:   Sat Jan 17 16:01:44 2026 -0300

    fold-const.cc: remove strict_overflow_p from tree_unary_nonzero_warnv_p
    
    This helper is called by tree_expr_nonzero_warnv_p(), a helper that is
    gating a call to fold_overflow_warning() that we want to eliminate.
    
    For now let's change the comment from tree_expr_nonzero_warnv_p() to
    mention that we're throwing overflow warnings just for certain cases,
    not all. We'll change that comment again when we get to work on
    tree_expr_nonzero_warnv_p().
    
    The helper is renamed to remove the "warn" from its name since it
    doesn't throw or set any overflow warnings anymore.
    
    gcc/ChangeLog:
    
            * fold-const.cc (mask_with_tz): Changed comment that describes
            tree_expr_nonzero_warnv_p warn on overflow behavior.
            (tree_expr_nonzero_warnv_p): Removed strict_overflow_p flag.
            (tree_unary_nonzero_warnv_p): Renamed to tree_unary_nonzero_p.
            (tree_unary_nonzero_p): Removed strict_overflow_p flag.
            * fold-const.h (tree_unary_nonzero_warnv_p): Renamed to
            tree_unary_nonzero_p.
            (tree_unary_nonzero_p): Removed strict_overflow_p flag.

Diff:
---
 gcc/fold-const.cc | 29 ++++++++++++-----------------
 gcc/fold-const.h  |  2 +-
 2 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index fbd1c89aafaa..2b984d0afefb 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -10804,9 +10804,10 @@ mask_with_tz (tree type, const wide_int &x, const 
wide_int &y)
    For floating point we further ensure that T is not denormal.
    Similar logic is present in nonzero_address in rtlanal.h.
 
-   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.  */
+   For certain tree code classes, 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.  */
 
 static bool
 tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
@@ -10822,8 +10823,7 @@ tree_expr_nonzero_warnv_p (tree t, bool 
*strict_overflow_p)
   switch (TREE_CODE_CLASS (code))
     {
     case tcc_unary:
-      return tree_unary_nonzero_warnv_p (code, type, TREE_OPERAND (t, 0),
-                                             strict_overflow_p);
+      return tree_unary_nonzero_p (code, type, TREE_OPERAND (t, 0));
     case tcc_binary:
     case tcc_comparison:
       return tree_binary_nonzero_warnv_p (code, type,
@@ -10842,8 +10842,7 @@ tree_expr_nonzero_warnv_p (tree t, bool 
*strict_overflow_p)
   switch (code)
     {
     case TRUTH_NOT_EXPR:
-      return tree_unary_nonzero_warnv_p (code, type, TREE_OPERAND (t, 0),
-                                             strict_overflow_p);
+      return tree_unary_nonzero_p (code, type, TREE_OPERAND (t, 0));
 
     case TRUTH_AND_EXPR:
     case TRUTH_OR_EXPR:
@@ -15236,21 +15235,17 @@ tree_expr_nonnegative_p (tree t)
 
 /* Return true when (CODE OP0) is an address and is known to be nonzero.
    For floating point we further ensure that T is not denormal.
-   Similar logic is present in nonzero_address in rtlanal.h.
-
-   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.  */
+   Similar logic is present in nonzero_address in rtlanal.h.  */
 
 bool
-tree_unary_nonzero_warnv_p (enum tree_code code, tree type, tree op0,
-                                bool *strict_overflow_p)
+tree_unary_nonzero_p (enum tree_code code, tree type, tree op0)
 {
+  bool sub_strict_overflow_p = false;
   switch (code)
     {
     case ABS_EXPR:
       return tree_expr_nonzero_warnv_p (op0,
-                                       strict_overflow_p);
+                                       &sub_strict_overflow_p);
 
     case NOP_EXPR:
       {
@@ -15259,13 +15254,13 @@ tree_unary_nonzero_warnv_p (enum tree_code code, tree 
type, tree op0,
 
        return (TYPE_PRECISION (outer_type) >= TYPE_PRECISION (inner_type)
                && tree_expr_nonzero_warnv_p (op0,
-                                             strict_overflow_p));
+                                             &sub_strict_overflow_p));
       }
       break;
 
     case NON_LVALUE_EXPR:
       return tree_expr_nonzero_warnv_p (op0,
-                                       strict_overflow_p);
+                                       &sub_strict_overflow_p);
 
     default:
       break;
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 49d481398a77..0e6b3306034c 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -162,7 +162,7 @@ extern bool ptr_difference_const (tree, tree, poly_int64 *);
 extern enum tree_code invert_tree_comparison (enum tree_code, bool);
 extern bool inverse_conditions_p (const_tree, const_tree);
 
-extern bool tree_unary_nonzero_warnv_p (enum tree_code, tree, tree, bool *);
+extern bool tree_unary_nonzero_p (enum tree_code, tree, tree);
 extern bool tree_binary_nonzero_warnv_p (enum tree_code, tree, tree, tree op1,
                                          bool *);
 extern bool tree_single_nonzero_warnv_p (tree, bool *);

Reply via email to