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

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

https://gcc.gnu.org/g:f61ae2cb8d38929cb3761631160fdfa58e59fdc4

commit r17-6425-gf61ae2cb8d38929cb3761631160fdfa58e59fdc4
Author: Richard Biener <[email protected]>
Date:   Wed Nov 18 15:20:02 2026 +0100

    tree-optimization/128672 - avoid UB in CSE of -x / y

    When we try to CSE -x / y with x / y we have to avoid presenting
    a negate as if it were in the IL to the match-and-simplify machinery.
    Instead we have to check whether the negate is available literally
    when negation may invoke UB.  The identity also doesn't hold for
    INT_MIN.

            PR tree-optimization/128672
            * tree-ssa-sccvn.cc (visit_nary_op): Check whether a negated
            operand of a division or multiplication is available, do not
            just attempt to build or simplify it, when the negation may
            cause UB.  Only handle TRUNC_DIV_EXPR when x cannot be INT_MIN.

            * gcc.dg/torture/pr128672-1.c: New testcase.
            * gcc.dg/torture/pr128672-2.c: Likewise.

Reply via email to