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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tamar Christina <tnfch...@gcc.gnu.org>:

https://gcc.gnu.org/g:217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4

commit r14-4746-g217a0fcb852aeb4aa9e3fb9baec6ff947c8de3d4
Author: Tamar Christina <tamar.christ...@arm.com>
Date:   Thu Oct 19 13:44:01 2023 +0100

    middle-end: don't create LC-SSA PHI variables for PHI nodes who dominate
loop

    As the testcase shows, when a PHI node dominates the loop there is no new
    definition inside the loop.  As such there would be no PHI nodes to update.

    When we maintain LCSSA form we create an intermediate node in between the
two
    loops to thread alongt the value.  However later on when we update the
second
    loop we don't have any PHI nodes to update and so
adjust_phi_and_debug_stmts
    does nothing.   This leaves us with an incorrect phi node.  Normally this
does
    nothing and just gets ignored.  But in the case of the vUSE chain we end up
    corrupting the chain.

    As such whenever a PHI node's argument dominates the loop, we should remove
    the newly created PHI node after edge redirection.

    The one exception to this is when the loop has been versioned.  In such
cases
    the versioned loop may not use the value but the second loop can.

    When this happens and we add the loop guard unless the join block has the
PHI
    it can't find the original value for use inside the guard block.

    The next refactoring in the series moves the formation of the guard block
    inside peeling itself.  Here we have all the information and wouldn't
    need to re-create it later.

    gcc/ChangeLog:

            PR tree-optimization/111860
            * tree-vect-loop-manip.cc (slpeel_tree_duplicate_loop_to_edge_cfg):
            Remove PHI nodes that dominate loop.

    gcc/testsuite/ChangeLog:

            PR tree-optimization/111860
            * gcc.dg/vect/pr111860.c: New test.

Reply via email to