https://gcc.gnu.org/g:6712abb759a0be27cbf3019bf77a313c5bb86796
commit r17-357-g6712abb759a0be27cbf3019bf77a313c5bb86796 Author: Andrew MacLeod <[email protected]> Date: Mon Dec 15 16:26:19 2025 -0500 Handle integer constants up front. If passed an integer constant, return that constant. * gimple-fold.cc (get_maxval_strlen): Return the same value if passed a constant. Diff: --- gcc/gimple-fold.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 4ec6cc65e3a7..652390442555 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -2012,6 +2012,11 @@ get_maxval_strlen (tree arg, strlen_range_kind rkind, tree *nonstr = NULL) /* A non-null NONSTR is meaningless when determining the maximum value of an integer ARG. */ gcc_assert (rkind != SRK_INT_VALUE || nonstr == NULL); + + // If arg is already a constant, simply return it. + if (TREE_CODE (arg) == INTEGER_CST && rkind == SRK_INT_VALUE) + return arg; + /* ARG must have an integral type when RKIND says so. */ gcc_assert (rkind != SRK_INT_VALUE || INTEGRAL_TYPE_P (TREE_TYPE (arg)));
