https://gcc.gnu.org/g:214985f6b35ea8038c4e96590b435aaef2919769
commit r15-5822-g214985f6b35ea8038c4e96590b435aaef2919769 Author: Georg-Johann Lay <a...@gjlay.de> Date: Sat Nov 30 14:58:05 2024 +0100 AVR: ad target/84211 - Split MOVW into MOVs in try_split_any. When splitting multi-byte REG-REG moves in try_split_any(), it's not clear whether propagating constants will turn out as profitable. When MOVW is available, split into REG-REG moves instead of a possible REG-CONST. gcc/ PR target/84211 * config/avr/avr-passes.cc (try_split_any) [SET, MOVW]: Prefer reg=reg move over reg=const when splitting a reg=reg insn. Diff: --- gcc/config/avr/avr-passes.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc index 68ebd31390ec..7be5ec25fbce 100644 --- a/gcc/config/avr/avr-passes.cc +++ b/gcc/config/avr/avr-passes.cc @@ -2912,6 +2912,14 @@ optimize_data_t::try_split_any (bbinfo_t *) xsrc = gen_rtx_REG (HImode, r16); i += step; } + // ...or a reg-reg move from a multi-byte move... + else if (r_src + // Prefer a reg-reg move over a (potential) load + // of a constant, because the subsequent RTL + // peephole pass may combine it to a MOVW again. + && AVR_HAVE_MOVW + && REG_P (curr.ii.m_src)) + xsrc = gen_rtx_REG (QImode, r_src); // ...or a cheap constant... else if (val8 >= 0 && AVRasm::constant_cost (SET, r_dest, val8) <= 1)