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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <[email protected]>:

https://gcc.gnu.org/g:4fe2072d5d16ce26112d8035e627d47809aaa6c2

commit r17-3330-g4fe2072d5d16ce26112d8035e627d47809aaa6c2
Author: Richard Biener <[email protected]>
Date:   Mon Aug 17 09:58:27 2026 +0200

    tree-optimization/126887 - allow backward threading to loop exit

    The following allows the backward thread through a loop header
    to exit, allowing it to fully peel a not iterating loop on a
    threading path.  The backward thread copier cannot handle copying
    loops, but this special case is OK and is also handled by the
    forward threader.  We have to take care to not randomly peel
    loops though, not even after loop opts, so this patch adds
    appropriate measures and a testcase.

            PR tree-optimization/126887
            * tree-ssa-threadbackward.cc (back_threader::find_paths_to_names):
            Allow to search past a loop header in case we are threading a
            loop exit test.
            * tree-ssa-threadupdate.cc
            (back_jt_path_registry::duplicate_thread_path): Properly
            detect when a entered subloop is dissolved by threading,
            but avoid creating new entries into the original loop.
            (jt_path_registry::cancel_invalid_paths): Do not allow
            peeling loops.

            * gcc.dg/tree-ssa/ssa-thread-23.c: New testcase.
            * gcc.dg/tree-ssa/ssa-thread-24.c: Likewise.

Reply via email to