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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Richard Sandiford <rsand...@gcc.gnu.org>:

https://gcc.gnu.org/g:3dbcf794f0fe89443288143405718d72e7963805

commit r15-7162-g3dbcf794f0fe89443288143405718d72e7963805
Author: Richard Sandiford <richard.sandif...@arm.com>
Date:   Thu Jan 23 13:57:02 2025 +0000

    rtl-ssa: Avoid dangling phi uses [PR118562]

    rtl-ssa uses degenerate phis to maintain an RPO list of
    accesses in which every use is of the RPO-previous definition.
    Thus, if it finds that a phi is always equal to a particular
    value V, it sometimes needs to keep the phi and make V the
    single input, rather than replace all uses of the phi with V.

    The code to do that rerouted the phi's first input to the single
    value V.  But as this PR shows, it failed to unlink the uses of
    the other inputs.

    The specific problem in the PR was that we had:

        x = PHI<x(a), V(b)>

    The code replaced the first input with V and removed the second
    input from the phi, but it didn't unlink the use of V associated
    with that second input.

    gcc/
            PR rtl-optimization/118562
            * rtl-ssa/blocks.cc (function_info::replace_phi): When converting
            to a degenerate phi, make sure to remove all uses of the previous
            inputs.

    gcc/testsuite/
            PR rtl-optimization/118562
            * gcc.dg/torture/pr118562.c: New test.

Reply via email to