https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87852
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
And fwprop before that questionable code does
/* We used to have a def reaching a use that is _before_ the def,
with the def not dominating the use even though the use and def
are in the same basic block, when a register may be used
uninitialized in a loop. This should not happen anymore since
we do not use reaching definitions, but still we test for such
cases and assume that DEF is not available. */
if (def_bb == target_bb
? DF_INSN_LUID (def_insn) >= DF_INSN_LUID (target_insn)
: !dominated_by_p (CDI_DOMINATORS, target_bb, def_bb))
return true;
so that suggests a fix like the following which fixes the testcase for me
diff --git a/gcc/fwprop.c b/gcc/fwprop.c
index 0fca0f1edbc..cd44c0ef637 100644
--- a/gcc/fwprop.c
+++ b/gcc/fwprop.c
@@ -767,7 +767,11 @@ use_killed_between (df_ref use, rtx_insn *def_insn,
rtx_insn *target_insn)
def = DF_REG_DEF_CHAIN (regno);
if (def
&& DF_REF_NEXT_REG (def) == NULL
- && regno >= FIRST_PSEUDO_REGISTER)
+ && regno >= FIRST_PSEUDO_REGISTER
+ && (BLOCK_FOR_INSN (DF_REF_INSN (def)) == def_bb
+ ? DF_INSN_LUID (DF_REF_INSN (def)) < DF_INSN_LUID (def_insn)
+ : dominated_by_p (CDI_DOMINATORS,
+ def_bb, BLOCK_FOR_INSN (DF_REF_INSN (def)))))
return false;
/* Check locally if we are in the same basic block. */