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

--- Comment #1 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:e35b8dad030bc4164fdaa81dc0a5bfca8c1bbfc3

commit r17-4469-ge35b8dad030bc4164fdaa81dc0a5bfca8c1bbfc3
Author: Andrea Pinski <[email protected]>
Date:   Tue Aug 25 14:47:38 2026 -0700

    cselim: cond_if_else_store_replacement_limited support skipping on store
one either side [PR127053]

    I noticed this while working on std::optional, the full blown cselim with
data references
    hanldes the case where there are a few stores on either side of the branch
that don't
    interfer with the other stores.  We could just support clobbers but that
would have
    a similar code except for an extra check for clobbers.  So let's just add
support
    for skipping on store on either side of the conditional too.

    The change to trailing_store_in_bb simplifies some things as already the
other
    side would check on the store being a simple assign, this does not change
anything.

    Note cselim-1.c was reduced from a draft version of this patch which was
miscompiling isl.
    In the whole testsuite the only regressions were in graphite.  So I thought
it would
    be a good idea to have a testcase to be added for the miscompiling case.  I
had forgot
    some stores could also be loads so another check was needed in that case.

    This was found by looking into std::optional::reset code gen.

    Changes since v1:
    * v2: skip stores and not just clobbers

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/127053

    gcc/ChangeLog:

            * tree-ssa-phiopt.cc (trailing_store_in_bb): Rename vphi to
            vuse_only.
            (cond_if_else_store_replacement_limited): Add case if
            cond_if_else_store_replacement_1 failed, allowing
            for skipping one store on each side.
            (trailing_store_in_bb): Require the store stmt
            to be a gimple simple assign.

    gcc/testsuite/ChangeLog:

            * g++.dg/tree-ssa/cselim-2.C: New test.
            * gcc.dg/torture/cselim-1.c: New test.

    Signed-off-by: Andrea Pinski <[email protected]>
  • [Bug tree-optimization/127053] ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to