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

--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrea Pinski <[email protected]>:

https://gcc.gnu.org/g:1ef005a99c1cda79daf1340677c7d7f01d261216

commit r17-4040-g1ef005a99c1cda79daf1340677c7d7f01d261216
Author: Andrea Pinski <[email protected]>
Date:   Tue Sep 8 12:06:22 2026 -0700

    VN: Fix insert_predicates_for_cond infinite recusion for `a != 0` handling
[PR127261]

    The fix for PR 117859 (r15-5844-ge1009b3de2d057) was not robust
    enough to stop some infinite recusion happening.
    What happens in this case is we have:
    c15_30 = g24_a1.3_8 != c14_12;

    And _8 is valueized as 0 and _12 is valueized as _30.
    But we don't realize that _30 didn't change here as
    the comparison is not canonicalized before the testing
    but rather after inside insert_predicates_for_cond.

    This adds the canonicalization before testing for infinite
    recusion which allows us to stop the recusion.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/127261

    gcc/ChangeLog:

            * tree-ssa-sccvn.cc (insert_predicates_for_cond): Canonicalize
            the comparison before testing for recusion.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr127261-1.c: New test.

    Signed-off-by: Andrea Pinski <[email protected]>

Reply via email to