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

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

https://gcc.gnu.org/g:46ee9bbc9a7d92eb3435999b59c3d8b42254f88a

commit r17-4415-g46ee9bbc9a7d92eb3435999b59c3d8b42254f88a
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Fri Sep 18 06:50:31 2026 -0400

    tree-optimization: Restrict (X {+,-} M*N) / N optimization. [PR127406]

    When X is INT_MIN and N is -1, then
    r14-3644 converts ((X {+,-} M*N) / N) to
    ((X / N) {+,-} M). But INT_MIN / -1 overflows where
    ((X {+,-} M*N) / N) does not.
    Add a check for ((X {+,-} M*N) / N) via X > INT_MIN
    and N != -1.

    Bootstrapped and regtested on x86_64-pc-linux-gnu.

            PR tree-optimization/127406

    gcc/ChangeLog:

            * match.pd: Restrict (X {+,-} M*N) / N optimization.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr127406.c: New test.

    Signed-off-by: Kael Andrew Franco <[email protected]>

Reply via email to