https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125475
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:a94d2d065efd35473c113cfb38b87234218341a3 commit r17-992-ga94d2d065efd35473c113cfb38b87234218341a3 Author: Andrew Pinski <[email protected]> Date: Wed May 27 21:09:01 2026 -0700 ranger-fold: Don't call into gimple_stmt_nonnegative_p [PR125475] 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. Signed-off-by: Andrew Pinski <[email protected]>
