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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

https://gcc.gnu.org/g:0c69007b1fb98d0fe03d61d81a51e4fc6ac98ce9

commit r16-5246-g0c69007b1fb98d0fe03d61d81a51e4fc6ac98ce9
Author: Andrew Pinski <[email protected]>
Date:   Wed Nov 12 21:06:02 2025 -0800

    sccp: Fix order of gimplification, removal of the phi and constant prop in
sccp (3rd time) [PR122637]

    This is 3rd (and hopefully last) time to fix the order here.
    The previous times were r16-5093-g77e10b47f25d05 and
r16-4905-g7b9d32aa2ffcb5.
    The order before these patches were:
    * removal of phi
    * propagate constants
    * gimplification of expr
    * create assignment
    * rewrite to undefined
    * add stmts to bb

    The current order before this patch (and after the other 2):
    * gimplification of expr
    * removal of phi
    * create assignment
    * propagate constants
    * rewrite to undefined
    * add stmts to bb

    The correct and new order with this patch we have:
    * gimplifcation of expr
    * propagate constants
    * removal of phi
    * create the assignment
    * rewrite to undefined
    * add stmts to bb

    This is because the propagate of the constant will cause a fold_stmt which
requires
    the statement in the IR still. The gimplifcation of expr also calls
fold_stmt.
    Now with the new order the phi is not removed until right before the
creation of the
    new assigment so the IR in the basic block is well defined while calling
fold_stmt.

    Pushed as obvious after bootstrap/test on x86_64-linux-gnu.

            PR tree-optimization/122637

    gcc/ChangeLog:

            * tree-scalar-evolution.cc (final_value_replacement_loop): Fix
order
            of gimplification and constant prop.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr122637-1.c: New test.

    Signed-off-by: Andrew Pinski <[email protected]>

Reply via email to