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

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

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

commit r17-6460-gae937b5ba700b3d9883505d73c59983863696d3c
Author: Kyrylo Tkachov <[email protected]>
Date:   Wed Nov 18 06:24:37 2026 -0800

    tree-optimization/128641 - predcom chains must be TBAA-equivalent

    pcom_worker::determine_offset places two references in the same chain
    when their types satisfy useless_type_conversion_p.  On LP64 long and
    long long satisfy it but have different alias sets.  References created
    for a chain (ref_at_iteration) copy the alias info of the chain root.
    In the PR a long store and a long long load form one chain, so the
    preheader load of the long long location is created as a long access.
    With the IPA modref summary of f, which only writes long long, TBAA then
    treats the long load as independent of the call f (b) and the value is
    read before the call, giving 0 instead of 7.

    Require refs_same_for_tbaa_p in determine_offset, in addition to the
    type check.  The chain root is not known there and can change when the
    chain is sorted by offset, so check both directions.  Every reference
    in a chain then has the same TBAA behaviour as its root.

    Bootstrapped and tested on aarch64-linux-gnu.

    gcc/ChangeLog:

            PR tree-optimization/128641
            * tree-predcom.cc (pcom_worker::determine_offset): Also require
            refs_same_for_tbaa_p in both directions for the two references.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/128641
            * gcc.dg/torture/pr128641.c: New test.
            * gcc.dg/torture/pr128641-2.c: Likewise.

    Signed-off-by: Kyrylo Tkachov <[email protected]>

Reply via email to