https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104581
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Since targetm.mode_switching.needed is called as part of the mode-switching
dataflow problem I don't see how looking at reg refs should be needed at all.
What might be needed and what I'm not sure is available, is the mode-switching
state of uses. The relevant call is
FOR_BB_INSNS (bb, insn)
{
if (INSN_P (insn))
{
int mode = targetm.mode_switching.needed (e, insn);
and indeed all the time is spent in
/* Check if DEF_INSN is before INSN. */
rtx_insn *next;
for (next = NEXT_INSN (def_insn);
next != nullptr && next != end && next != insn;
next = NEXT_INSN (next))
;