https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125291

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <[email protected]>:

https://gcc.gnu.org/g:26aae2119eb79bfbea23b86ea1a58f9a3a0911a6

commit r17-529-g26aae2119eb79bfbea23b86ea1a58f9a3a0911a6
Author: Xi Ruoyao <[email protected]>
Date:   Wed May 13 00:22:15 2026 +0800

    scev: Sign extend step in peeled converted IV handling [PR 125291]

    For 3 iterations of

        unsigned char flagbits;
        _877 = flagbits_832 + 254;
        _879 = (int) _877;
        # prephitmp_880 = PHI <_879(40), 6(41)>
        _70 = _68 >> prephitmp_880;

    The peeled converted IV handling added in r16-3562 incorrectly analyzes
    it as [6, 6 + 254, 6 + 254 * 2] instead of [6, 4, 2].  Then VRP uses the
    intersect of {6, 560, 514} and {2, 4, 6}, i.e. {6} as the possible value
    range, and propagates the constant 6 for _70.

    Extend the step (for example, 254 => -2) to fix the issue.

            PR tree-optimization/125291

    gcc/

            * tree-scalar-evolution.cc (simplify_peeled_chrec): Sign-extend
            the step for peeled converted IV.

    gcc/testsuite/

            * gcc.c-torture/execute/pr125291.c: New test.

Reply via email to