https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113533
Roger Sayle <roger at nextmovesoftware dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2024-01-22 Status|UNCONFIRMED |NEW CC| |roger at nextmovesoftware dot com Ever confirmed|0 |1 --- Comment #6 from Roger Sayle <roger at nextmovesoftware dot com> --- To help diagnose the problem, I came up with this simple patch: diff --git a/gcc/fwprop.cc b/gcc/fwprop.cc index 7872609b336..dc563ac2ca1 100644 --- a/gcc/fwprop.cc +++ b/gcc/fwprop.cc @@ -492,6 +492,9 @@ try_fwprop_subst_pattern (obstack_watermark &attempt, insn_change &use_change, " (cost %d -> cost %d)\n", old_cost, new_cost); ok = false; } + else if (dump_file) + fprintf (dump_file, "change is profitable" + " (cost %d -> cost %d)\n", old_cost, new_cost); } if (!ok) which then helps reveal that on sh3-linux-gnu with -O1 we see: propagating insn 6 into insn 12, replacing: (set (reg:SI 174 [ _1 ]) (sign_extend:SI (reg:QI 169 [ *a_7(D) ]))) successfully matched this instruction to *extendqisi2_compact_snd: (set (reg:SI 174 [ _1 ]) (sign_extend:SI (mem:QI (reg/v/f:SI 168 [ aD.1817 ]) [0 *a_7(D)+0 S1 A8]))) change is profitable (cost 4 -> cost 1) which confirms Andrew's and Oleg's analyses above; the sh_rtx_costs function is a little odd... Reading from memory is four times faster than using a pseudo!? I'm investigating a "costs" patch for the SH backend. My apologies for the temporary inconvenience, and thanks to Jeff for catching/spotting this.