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

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

https://gcc.gnu.org/g:aa998156c69fcb70ed637f34fd86e47020254ce5

commit r10-10661-gaa998156c69fcb70ed637f34fd86e47020254ce5
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Dec 28 17:40:17 2021 +0100

    loop-invariant: Fix -fcompare-debug failure [PR103837]

    In the following testcase we have a -fcompare-debug failure, because
    can_move_invariant_reg doesn't ignore DEBUG_INSNs in its decisions.
    In the testcase we have due to uninitialized variable:
      loop_header
        debug_insn using pseudo84
        pseudo84 = invariant
        insn using pseudo84
      end loop
    and with -g decide not to move the pseudo84 = invariant before the
    loop header; in this case not resetting the debug insns might be fine.
    But, we could have also:
      pseudo84 = whatever
      loop_header
        debug_insn using pseudo84
        pseudo84 = invariant
        insn using pseudo84
      end loop
    and in that case not resetting the debug insns would result in wrong-debug.
    And, we don't really have generally a good substitution on what pseudo84
    contains, it could inherit various values from different paths.
    So, the following patch ignores DEBUG_INSNs in the decisions, and if there
    are any that previously prevented the optimization, resets them before
    return true.

    2021-12-28  Jakub Jelinek  <ja...@redhat.com>

            PR rtl-optimization/103837
            * loop-invariant.c (can_move_invariant_reg): Ignore DEBUG_INSNs in
            the decisions whether to return false or continue and right before
            returning true reset those debug insns that previously caused
            returning false.

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

    (cherry picked from commit 3c5fd3616f73fbcd241cc3a5e09275c2b0c49bd4)

Reply via email to