diff mbox series

[avr] ad PR84211: Prefer split into reg-reg move over reg-const move

Message ID cd69618d-c979-4199-846b-e125fe95bb76@gjlay.de
State New
Headers show
Series [avr] ad PR84211: Prefer split into reg-reg move over reg-const move | expand

Commit Message

Georg-Johann Lay Nov. 30, 2024, 2:22 p.m. UTC
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.

Johann

--

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 mbox series

Patch

    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 --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc
index 68ebd31390e..7be5ec25fbc 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)