On Wed, May 27, 2026 at 5:51 AM Daniel Barboza
<[email protected]> wrote:
>
> Continuing the deprecation of -Wstrict-overflow, remove the
> strict_overflow_p flag from range_entry and the two associated
> warning_at calls.


Ok, assume this was tested.

>
> gcc/ChangeLog:
>
>         * tree-ssa-reassoc.cc (init_range_entry): Removed
>         strict_overflow_p use.
>         (force_into_ssa_name): Likewise.
>         (update_range_test): Removed strict_overflow_p from function
>         signature, along with the flag associated logic and the
>         warning_at call.
>         (optimize_range_tests_xor): Removed strict_overflow_p use.
>         (optimize_range_tests_diff): Likewise.
>         (optimize_range_tests_to_bit_test): Likewise.
>         (optimize_range_tests_cmp_bitwise): Likewise.
>         (optimize_range_tests_var_bound): Removed strict_overflow_p from
>         function signature, along with the flag associated logic and the
>         warning_at call.
>         (optimize_range_tests): Removed strict_overflow_p use.
>         * tree-ssa-reassoc.h (struct range_entry): Removed
>         strict_overflow_p flag.
> ---
>  gcc/tree-ssa-reassoc.cc | 45 ++++++++---------------------------------
>  gcc/tree-ssa-reassoc.h  |  1 -
>  2 files changed, 8 insertions(+), 38 deletions(-)
>
> diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
> index db6f7118d2c..6bb408487dd 100644
> --- a/gcc/tree-ssa-reassoc.cc
> +++ b/gcc/tree-ssa-reassoc.cc
> @@ -2541,11 +2541,10 @@ init_range_entry (struct range_entry *r, tree exp, 
> gimple *stmt)
>  {
>    int in_p;
>    tree low, high;
> -  bool is_bool, strict_overflow_p;
> +  bool is_bool;
>
>    r->exp = NULL_TREE;
>    r->in_p = false;
> -  r->strict_overflow_p = false;
>    r->low = NULL_TREE;
>    r->high = NULL_TREE;
>    if (exp != NULL_TREE
> @@ -2560,7 +2559,6 @@ init_range_entry (struct range_entry *r, tree exp, 
> gimple *stmt)
>    low = exp ? build_int_cst (TREE_TYPE (exp), 0) : boolean_false_node;
>    high = low;
>    in_p = 0;
> -  strict_overflow_p = false;
>    is_bool = false;
>    if (exp == NULL_TREE)
>      is_bool = true;
> @@ -2677,7 +2675,6 @@ init_range_entry (struct range_entry *r, tree exp, 
> gimple *stmt)
>        r->in_p = in_p;
>        r->low = low;
>        r->high = high;
> -      r->strict_overflow_p = strict_overflow_p;
>      }
>  }
>
> @@ -2781,7 +2778,7 @@ force_into_ssa_name (gimple_stmt_iterator *gsi, tree 
> expr, bool before)
>  }
>
>  /* Helper routine of optimize_range_test.
> -   [EXP, IN_P, LOW, HIGH, STRICT_OVERFLOW_P] is a merged range for
> +   [EXP, IN_P, LOW, HIGH] is a merged range for
>     RANGE and OTHERRANGE through OTHERRANGE + COUNT - 1 ranges,
>     OPCODE and OPS are arguments of optimize_range_tests.  If OTHERRANGE
>     is NULL, OTHERRANGEP should not be and then OTHERRANGEP points to
> @@ -2797,7 +2794,7 @@ update_range_test (struct range_entry *range, struct 
> range_entry *otherrange,
>                    struct range_entry **otherrangep,
>                    unsigned int count, enum tree_code opcode,
>                    vec<operand_entry *> *ops, tree exp, gimple_seq seq,
> -                  bool in_p, tree low, tree high, bool strict_overflow_p)
> +                  bool in_p, tree low, tree high)
>  {
>    unsigned int idx = range->idx;
>    struct range_entry *swap_with = NULL;
> @@ -2849,7 +2846,6 @@ update_range_test (struct range_entry *range, struct 
> range_entry *otherrange,
>    tree optype = op ? TREE_TYPE (op) : boolean_type_node;
>    tree tem = build_range_check (loc, optype, unshare_expr (exp),
>                                 in_p, low, high);
> -  enum warn_strict_overflow_code wc = WARN_STRICT_OVERFLOW_COMPARISON;
>    gimple_stmt_iterator gsi;
>    unsigned int i, uid;
>
> @@ -2881,11 +2877,6 @@ update_range_test (struct range_entry *range, struct 
> range_entry *otherrange,
>    if (swap_with)
>      std::swap (range->idx, swap_with->idx);
>
> -  if (strict_overflow_p && issue_strict_overflow_warning (wc))
> -    warning_at (loc, OPT_Wstrict_overflow,
> -               "assuming signed overflow does not occur "
> -               "when simplifying range test");
> -
>    if (dump_file && (dump_flags & TDF_DETAILS))
>      {
>        struct range_entry *r;
> @@ -3007,7 +2998,6 @@ update_range_test (struct range_entry *range, struct 
> range_entry *otherrange,
>    range->low = low;
>    range->high = high;
>    range->in_p = in_p;
> -  range->strict_overflow_p = false;
>
>    for (i = 0; i < count; i++)
>      {
> @@ -3085,9 +3075,7 @@ optimize_range_tests_xor (enum tree_code opcode, tree 
> type,
>    lowj = fold_build2 (BIT_AND_EXPR, type, lowi, tem);
>    highj = fold_build2 (BIT_AND_EXPR, type, highi, tem);
>    if (update_range_test (rangei, rangej, NULL, 1, opcode, ops, exp,
> -                        NULL, rangei->in_p, lowj, highj,
> -                        rangei->strict_overflow_p
> -                        || rangej->strict_overflow_p))
> +                        NULL, rangei->in_p, lowj, highj))
>      return true;
>    return false;
>  }
> @@ -3143,9 +3131,7 @@ optimize_range_tests_diff (enum tree_code opcode, tree 
> type,
>    tem1 = fold_build2 (BIT_AND_EXPR, type, tem1, mask);
>    lowj = build_int_cst (type, 0);
>    if (update_range_test (rangei, rangej, NULL, 1, opcode, ops, tem1,
> -                        NULL, rangei->in_p, lowj, tem2,
> -                        rangei->strict_overflow_p
> -                        || rangej->strict_overflow_p))
> +                        NULL, rangei->in_p, lowj, tem2))
>      return true;
>    return false;
>  }
> @@ -3322,7 +3308,6 @@ optimize_range_tests_to_bit_test (enum tree_code 
> opcode, int first, int length,
>                                         highi, &mask, &lowi);
>        if (exp == NULL_TREE)
>         continue;
> -      bool strict_overflow_p = ranges[i].strict_overflow_p;
>        candidates.truncate (0);
>        int end = MIN (i + 64, length);
>        for (j = i + 1; j < end; j++)
> @@ -3361,7 +3346,6 @@ optimize_range_tests_to_bit_test (enum tree_code 
> opcode, int first, int length,
>           if (exp2 != exp)
>             continue;
>           mask |= mask2;
> -         strict_overflow_p |= ranges[j].strict_overflow_p;
>           candidates.safe_push (&ranges[j]);
>         }
>
> @@ -3487,7 +3471,7 @@ optimize_range_tests_to_bit_test (enum tree_code 
> opcode, int first, int length,
>           tree val = build_zero_cst (optype);
>           if (update_range_test (&ranges[i], NULL, candidates.address (),
>                                  candidates.length (), opcode, ops, exp,
> -                                seq, false, val, val, strict_overflow_p))
> +                                seq, false, val, val))
>             {
>               any_changes = true;
>               if (tem)
> @@ -3628,14 +3612,12 @@ optimize_range_tests_cmp_bitwise (enum tree_code 
> opcode, int first, int length,
>           }
>         tree type1 = TREE_TYPE (ranges[k - 1].exp);
>         tree type2 = NULL_TREE;
> -       bool strict_overflow_p = false;
>         candidates.truncate (0);
>         if (POINTER_TYPE_P (type1) || TREE_CODE (type1) == OFFSET_TYPE)
>           type1 = pointer_sized_int_node;
>         for (j = i; j; j = chains[j - 1])
>           {
>             tree type = TREE_TYPE (ranges[j - 1].exp);
> -           strict_overflow_p |= ranges[j - 1].strict_overflow_p;
>             if (POINTER_TYPE_P (type) || TREE_CODE (type) == OFFSET_TYPE)
>               type = pointer_sized_int_node;
>             if ((b % 4) == 3)
> @@ -3749,7 +3731,7 @@ optimize_range_tests_cmp_bitwise (enum tree_code 
> opcode, int first, int length,
>         if (update_range_test (&ranges[k - 1], NULL, candidates.address (),
>                                candidates.length (), opcode, ops, op,
>                                seq, ranges[k - 1].in_p, ranges[k - 1].low,
> -                              ranges[k - 1].high, strict_overflow_p))
> +                              ranges[k - 1].high))
>           any_changes = true;
>         else
>           gimple_seq_discard (seq);
> @@ -3955,14 +3937,6 @@ optimize_range_tests_var_bound (enum tree_code opcode, 
> int first, int length,
>          and RHS2 is known to be RHS2 >= 0.  */
>        tree utype = unsigned_type_for (TREE_TYPE (rhs1));
>
> -      enum warn_strict_overflow_code wc = WARN_STRICT_OVERFLOW_COMPARISON;
> -      if ((ranges[*idx].strict_overflow_p
> -          || ranges[i].strict_overflow_p)
> -         && issue_strict_overflow_warning (wc))
> -       warning_at (gimple_location (stmt), OPT_Wstrict_overflow,
> -                   "assuming signed overflow does not occur "
> -                   "when simplifying range test");
> -
>        if (dump_file && (dump_flags & TDF_DETAILS))
>         {
>           struct range_entry *r = &ranges[*idx];
> @@ -4044,7 +4018,6 @@ optimize_range_tests_var_bound (enum tree_code opcode, 
> int first, int length,
>           ranges[i].low = build_zero_cst (TREE_TYPE (ranges[i].exp));
>           ranges[i].high = ranges[i].low;
>         }
> -      ranges[i].strict_overflow_p = false;
>        oe = (*ops)[ranges[*idx].idx];
>        /* Now change all the other range test immediate uses, so that
>          those tests will be optimized away.  */
> @@ -4118,7 +4091,6 @@ optimize_range_tests (enum tree_code opcode,
>        tree low = ranges[i].low;
>        tree high = ranges[i].high;
>        int in_p = ranges[i].in_p;
> -      bool strict_overflow_p = ranges[i].strict_overflow_p;
>        int update_fail_count = 0;
>
>        for (j = i + 1; j < length; j++)
> @@ -4128,7 +4100,6 @@ optimize_range_tests (enum tree_code opcode,
>           if (!merge_ranges (&in_p, &low, &high, in_p, low, high,
>                              ranges[j].in_p, ranges[j].low, ranges[j].high))
>             break;
> -         strict_overflow_p |= ranges[j].strict_overflow_p;
>         }
>
>        if (j == i + 1)
> @@ -4136,7 +4107,7 @@ optimize_range_tests (enum tree_code opcode,
>
>        if (update_range_test (ranges + i, ranges + i + 1, NULL, j - i - 1,
>                              opcode, ops, ranges[i].exp, NULL, in_p,
> -                            low, high, strict_overflow_p))
> +                            low, high))
>         {
>           i = j - 1;
>           any_changes = true;
> diff --git a/gcc/tree-ssa-reassoc.h b/gcc/tree-ssa-reassoc.h
> index ddd462ee074..2e16acd6448 100644
> --- a/gcc/tree-ssa-reassoc.h
> +++ b/gcc/tree-ssa-reassoc.h
> @@ -36,7 +36,6 @@ struct range_entry
>    tree low;
>    tree high;
>    bool in_p;
> -  bool strict_overflow_p;
>    unsigned int idx, next;
>  };
>
> --
> 2.43.0
>

Reply via email to