On 5/28/2026 9:23 AM, Andrew Pinski wrote:
> When fold_using_range::fold_stmt comes in with a varying range,
> it currently calls gimple_stmt_nonnegative_p to see if the value
> is non-negative. But in the case where it matters (pr33738.C),
> it will return true always because here we have just an unsigned type.
> That sets the range to `[0, type_max]`. So instead we should
> check if the type_min/type_max is not the same as precisionmin/precisionmax
> and set the range to `[type_min, type_max]` in that case.
>
> This fixes a recusion if we change tree_expr_nonnegative_p over to use
> the ranger and I suspect might it help Ada code too.
>
>       PR tree-optimization/125475
>
> gcc/ChangeLog:
>
>       * gimple-range-fold.cc (fold_using_range::fold_stmt): Don't call
>       gimple_stmt_nonnegative_p. Instead set the varying range to
>       `[type_min, type_max]` if not the same as the precision.
OK
jeff

Reply via email to