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

--- Comment #14 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>:

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

commit r16-3936-ga7a9f0de4fe01ee96350892066afbe5aca4bc0a6
Author: Andrew Pinski <andrew.pin...@oss.qualcomm.com>
Date:   Tue Sep 16 10:55:03 2025 -0700

    forwprop: Fix up "nop" copies after recent changes [PR121962]

    After r16-3887-g597b50abb0d2fc, the check to see if the copy is
    a nop copy becomes inefficient. The code going into an infinite
    loop as the copy keeps on being propagated over and over again.

    That is if we have:
    ```
      struct s1 *b = &a.t;
      a.t = *b;
      p = *b;
    ```

    This goes into an infinite loop propagating over and over again the
    `MEM[&a]`.
    To solve this a new function is needed for the comparison that is
    similar to new_src_based_on_copy.

            PR tree-optimization/121962

    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (same_for_assignment): New function.
            (optimize_agr_copyprop_1): Use same_for_assignment to check for
            nop copies.
            (optimize_agr_copyprop): Likewise.

    gcc/testsuite/ChangeLog:

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

    Signed-off-by: Andrew Pinski <andrew.pin...@oss.qualcomm.com>

Reply via email to