[Bug target/121957] [15/16/17 Regression] AArch64: Miscompile at -O2/O3 since r15-1579-g792f97b44ffc5e

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121957

--- Comment #10 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Kyrylo Tkachov
<[email protected]>:

https://gcc.gnu.org/g:7d85832d09f9959a2dea95d956f54f70eabde1f7

commit r16-9385-g7d85832d09f9959a2dea95d956f54f70eabde1f7
Author: Kyrylo Tkachov <[email protected]>
Date:   Tue Jul 7 03:24:44 2026 -0700

    out-of-SSA: use the spill predicate for partition decls [PR123625,
PR121957]

    Changes in v2:
    - Match the exact expansion spill predicate instead of using BLKmode.
    - Add a non-BLKmode -ffloat-store regression.

    Out-of-SSA can leave several partitions sharing one base VAR_DECL when its
    SSA versions have overlapping live ranges.  If those partitions are
spilled,
    set_mem_attributes gives every stack slot the same MEM_EXPR at offset zero.
    MEM_EXPR-based disambiguation can then combine accesses from distinct
slots.

    Split the overlapping partitions after TER, using the same
    use_register_for_decl predicate as expansion rather than approximating the
    memory decision with BLKmode.  Keep the default-definition partition tied
to
    the original decl and give the other partitions artificial decls with debug
    expressions referring back to it.

    Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.

    gcc/ChangeLog:

            PR target/123625
            PR target/121957
            * tree-outof-ssa.cc (split_overlapping_partition_decls): New
function.
            Use use_register_for_decl to identify memory partitions.
            (remove_ssa_form): Call split_overlapping_partition_decls.

    gcc/testsuite/ChangeLog:

            PR target/123625
            PR target/121957
            * gcc.c-torture/execute/pr121957.c: New test.
            * gcc.c-torture/execute/pr123625.c: New test.
            * gcc.c-torture/execute/pr123625-2.c: New test.
            * gcc.c-torture/execute/pr123625-3.c: New test.
            * gcc.dg/pr123625-1.c: New test.

    Signed-off-by: Kyrylo Tkachov <[email protected]>
    (cherry picked from commit 9aab80ddc5b2fa0eef80008e718067ab45f42c50)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.