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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:1774ab84863202f5db694914b67e3aef8c6dd807

commit r12-8090-g1774ab84863202f5db694914b67e3aef8c6dd807
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Apr 11 19:06:59 2022 +0200

    phiopt: Fix up debug handling in the (x != cst1 ? x : cst2) != cst3 opt
[PR105218]

    In the PR104639 optimization, I've added code to emit
      # DEBUG D#1 => arg != carg ? arg : oarg
    instruction and replace debug uses of the phi with that debug
    temp, so that the debug info is still accurrate.
    Unfortunately, that is only correct if the middle-bb and
    phi bb contain 1 and 2 predecessors, i.e. the ones that
    we are using in the optimization (in particular middle-bb has
    cond-bb as pred and phi bb cond-bb and middle-bb).
    If that is not the case, then we can reach these from another bb
    and so the arg SSA_NAME might not be valid there (its definition
    doesn't dominate all incoming edges), or, even if it is valid,
    might be wrong-debug, e.g. phi argument from some unrelated other
    incoming edge might have the carg value that the debug stmt
    remaps to oarg.  In theory we could check for that case and
    if middle-bb doesn't have a single pred or phi bb 2 preds
    check if arg SSA_NAME dominates the phi bb and if all other
    phi arguments are expr_not_equal_to the carg value, but this patch
    just uses a simpler approach and resets already if we have some
    extra incoming edges.

    2022-04-11  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/105218
            * tree-ssa-phiopt.cc (value_replacement): If middle_bb has
            more than one predecessor or phi's bb more than 2 predecessors,
            reset phi result uses instead of adding a debug temp.

            * gcc.dg/pr105218.c: New test.

Reply via email to