On 9/9/26 6:07 PM, Andrea Pinski wrote:
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]>
OK.  Sorry about the long wait.

jeff

Reply via email to