http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54294

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-08-17 
10:29:20 UTC ---
Created attachment 28041
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28041
gcc48-pr54294.patch

Seems my other PR42728 patch fixes the -fcompare-debug failure and is IMHO
desirable in any case.  What is going on here is that we have:
(insn 14254 14253 512 423 (set (reg:DI 1196 [ ei ])
        (sign_extend:DI (subreg:SI (reg:DI 1196 [ ei ]) 0))) 2 {*extendsidi2_1}
     (nil))
insn where (subreg:SI (reg:DI 1196 [ ei ]) 0) is replaced by (reg:SI 2915). 
But fwprop is df_set_flags (DF_DEFER_INSN_RESCAN);.  When replacing the next
insn,
which without -g turns to be another set, but with -g there are several debug
insns in between and next insn is the first of them, we take a shortcut.  As
rescan is deferred, we see both 1196 and 2915 regs as "uses" of def_insn.  The
shortcut performs a rtx_equal_p check on DF_REF_REG (use) which fails though,
as DF_REF_REG (use) is the subreg, thus we replace the subreg in the
immediately following insn.  But when trying to replace it in following debug
insns and with -g in the first following non-debug insn, it is not NEXT_INSN,
shortcut is not taken and we do both the rtx_equal_p check (fine, DF_REF_REG is
again a subreg), but also do use_killed_between including def_insn, and that
calls local_ref_killed_between_p, which compares DF_REF_REGNO instead of using
rtx_equal_p and therefore says that the (already non-existing) use in def_insn
is killed by the set in the def_insn.

So, IMHO we should possibly replace the rtx_equal_p checks with simple
DF_REF_REGNO comparisons instead, which will be more conservatively correct,
but we risk code quality regressions.

So, perhaps another thing to do could be that when walking uses of def_insn in
all_uses_available_at, we'd double check if the reg in question is really still
used in the insn pattern (perhaps conditionally on whether the insn is still
marked for rescanning or not).

Reply via email to