https://gcc.gnu.org/g:e27a905ad03c0e8cbbefb0d94f14dc570ad233f1
commit r17-692-ge27a905ad03c0e8cbbefb0d94f14dc570ad233f1 Author: Daniel Barboza <[email protected]> Date: Sat Jan 17 16:01:46 2026 -0300 fold-const.cc: remove strict_overflow_p from tree_single_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. The helper is renamed to remove the "warn" from its name since it doesn't throw or set any overflow warnings anymore. gcc/c-family/ChangeLog: * c-ubsan.cc (ubsan_maybe_instrument_reference_or_call): Removed strict_overflow_p flag. gcc/ChangeLog: * fold-const.cc (tree_expr_nonzero_warnv_p): Removed strict_overflow_p flag. (tree_single_nonzero_warnv_p): Renamed to tree_single_nonzero_p. (tree_single_nonzero_p): Removed strict_overflow_p flag. * fold-const.h (tree_single_nonzero_warnv_p): Renamed to tree_single_nonzero_p. (tree_single_nonzero_p): Removed strict_overflow_p flag. * gimple-range-fold.cc (fold_using_range::range_of_address): Removed strict_overflow_p flag. (range_from_readonly_load): Likewise. * ipa-prop.cc (ipa_compute_jump_functions_for_edge): Likewise. * tree-ssa-phiopt.cc (absorbing_element_p): Likewise. * value-query.cc (range_query::get_tree_range): Likewise. Diff: --- gcc/c-family/c-ubsan.cc | 6 ++---- gcc/fold-const.cc | 18 +++++------------- gcc/fold-const.h | 2 +- gcc/gimple-range-fold.cc | 6 ++---- gcc/ipa-prop.cc | 3 +-- gcc/tree-ssa-phiopt.cc | 2 +- gcc/value-query.cc | 3 +-- 7 files changed, 13 insertions(+), 27 deletions(-) diff --git a/gcc/c-family/c-ubsan.cc b/gcc/c-family/c-ubsan.cc index 2025a45cd76c..c757a4ce1c2a 100644 --- a/gcc/c-family/c-ubsan.cc +++ b/gcc/c-family/c-ubsan.cc @@ -920,16 +920,14 @@ ubsan_maybe_instrument_reference_or_call (location_t loc, tree op, tree ptype, { if (sanitize_flags_p (SANITIZE_NULL) && TREE_CODE (op) == ADDR_EXPR) { - bool strict_overflow_p = false; - /* tree_single_nonzero_warnv_p will not return true for non-weak + /* tree_single_nonzero_p will not return true for non-weak non-automatic decls with -fno-delete-null-pointer-checks, which is disabled during -fsanitize=null. We don't want to instrument those, just weak vars though. */ int save_flag_delete_null_pointer_checks = flag_delete_null_pointer_checks; flag_delete_null_pointer_checks = 1; - if (!tree_single_nonzero_warnv_p (op, &strict_overflow_p) - || strict_overflow_p) + if (!tree_single_nonzero_p (op)) instrument = true; flag_delete_null_pointer_checks = save_flag_delete_null_pointer_checks; diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 46a6a6b006b4..784cb4057b57 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -10832,7 +10832,7 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p) case tcc_constant: case tcc_declaration: case tcc_reference: - return tree_single_nonzero_warnv_p (t, strict_overflow_p); + return tree_single_nonzero_p (t); default: break; @@ -10856,7 +10856,7 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p) case ADDR_EXPR: case WITH_SIZE_EXPR: case SSA_NAME: - return tree_single_nonzero_warnv_p (t, strict_overflow_p); + return tree_single_nonzero_p (t); case COMPOUND_EXPR: case MODIFY_EXPR: @@ -15351,14 +15351,10 @@ tree_binary_nonzero_p (enum tree_code code, tree type, tree op0, tree op1) /* Return true when T 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_single_nonzero_warnv_p (tree t, bool *strict_overflow_p) +tree_single_nonzero_p (tree t) { bool sub_strict_overflow_p; switch (TREE_CODE (t)) @@ -15399,11 +15395,7 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p) &sub_strict_overflow_p) && tree_expr_nonzero_warnv_p (TREE_OPERAND (t, 2), &sub_strict_overflow_p)) - { - if (sub_strict_overflow_p) - *strict_overflow_p = true; - return true; - } + return true; break; case SSA_NAME: diff --git a/gcc/fold-const.h b/gcc/fold-const.h index 7bd2e31fff0d..d6de959c810c 100644 --- a/gcc/fold-const.h +++ b/gcc/fold-const.h @@ -164,7 +164,7 @@ extern bool inverse_conditions_p (const_tree, const_tree); extern bool tree_unary_nonzero_p (enum tree_code, tree, tree); extern bool tree_binary_nonzero_p (enum tree_code, tree, tree, tree op1); -extern bool tree_single_nonzero_warnv_p (tree, bool *); +extern bool tree_single_nonzero_p (tree); extern bool tree_unary_nonnegative_warnv_p (enum tree_code, tree, tree, bool *, int); extern bool tree_binary_nonnegative_warnv_p (enum tree_code, tree, tree, tree, diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 9119765125f8..88916209140e 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -842,7 +842,6 @@ fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &src) gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN); gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR); - bool strict_overflow_p; tree expr = gimple_assign_rhs1 (stmt); poly_int64 bitsize, bitpos; tree offset; @@ -910,7 +909,7 @@ fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &src) } // Handle "= &a". - if (tree_single_nonzero_warnv_p (expr, &strict_overflow_p)) + if (tree_single_nonzero_p (expr)) { r.set_nonzero (TREE_TYPE (gimple_assign_rhs1 (stmt))); return true; @@ -956,8 +955,7 @@ range_from_readonly_load (vrange &r, tree type, tree cst, if (POINTER_TYPE_P (type)) { - bool strict_overflow_p; - return tree_single_nonzero_warnv_p (cst, &strict_overflow_p); + return tree_single_nonzero_p (cst); } if (TREE_CODE (cst) != INTEGER_CST) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 6675c2191fcc..8fd8fcc977ab 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -2543,8 +2543,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, || vr.varying_p () || vr.undefined_p ()) { - bool strict_overflow = false; - if (tree_single_nonzero_warnv_p (arg, &strict_overflow)) + if (tree_single_nonzero_p (arg)) vr.set_nonzero (TREE_TYPE (arg)); else vr.set_varying (TREE_TYPE (arg)); diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 18b5f284eee4..1c04a9b0f7c3 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1329,7 +1329,7 @@ absorbing_element_p (tree_code code, tree arg, bool right, tree rval) case ROUND_MOD_EXPR: return (!right && integer_zerop (arg) - && tree_single_nonzero_warnv_p (rval, NULL)); + && tree_single_nonzero_p (rval)); default: return false; diff --git a/gcc/value-query.cc b/gcc/value-query.cc index 3f50e31a9f44..e7a75832cb4b 100644 --- a/gcc/value-query.cc +++ b/gcc/value-query.cc @@ -389,8 +389,7 @@ range_query::get_tree_range (vrange &r, tree expr, gimple *stmt, case ADDR_EXPR: { // Handle &var which can show up in phi arguments. - bool ov; - if (tree_single_nonzero_warnv_p (expr, &ov)) + if (tree_single_nonzero_p (expr)) { r.set_nonzero (type); return true;
