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

--- Comment #8 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
I was going to say that force_subreg should call force_operand:

diff --git a/gcc/explow.cc b/gcc/explow.cc
index 7799a98053b..3f378174268 100644
--- a/gcc/explow.cc
+++ b/gcc/explow.cc
@@ -759,7 +759,9 @@ force_subreg (machine_mode outermode, rtx op,
   auto *start = get_last_insn ();
   op = copy_to_mode_reg (innermode, op);
   rtx res = simplify_gen_subreg (outermode, op, innermode, byte);
-  if (!res)
+  if (res)
+    res = force_operand (res, NULL_RTX);
+  else
     delete_insns_since (start);
   return res;
 }

But that doesn't work because force_operand considers the subreg to be valid
(and general_operand agrees).  So if this isn't a regression, it might be
better to wait until GCC 16 and disallow all (subreg (mem)) for
INSN_SCHEDULING.  (Or completely, if possible.)

Reply via email to