CRIS: peephole2 a move of constant followed by and of same register
commitfe50e419086f5b781b6fe8242741e6213b788337
authorHans-Peter Nilsson <hp@axis.com>
Thu, 20 Apr 2023 18:59:42 +0000 (20 20:59 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Fri, 5 May 2023 23:58:16 +0000 (6 01:58 +0200)
treee43b6e933fceededd394bbaa0d8c6ee9d130f040
parent0a5e8d492a7efc739110289bf97ef4c9fe0674f4
CRIS: peephole2 a move of constant followed by and of same register

While moves of constants into registers are separately
optimizable, a combination of a move with a subsequent "and"
is slightly preferable even if the move can be generated
with the same number (and timing) of insns, as moves of
"just" registers are eliminated now and then in different
passes, loosely speaking.  This movandsplit1 pattern feeds
into the opsplit1/AND peephole2, with matching occurrences
observed in the floating point functions in libgcc.  Also, a
test-case to fit.  Coremark improvements are unimpressive:
less than 0.0003% speed, 0.1% size.

But that was pre-LRA; after the switch to LRA this peephole2
doesn't match anymore (for any of coremark, local tests,
libgcc and newlib libc) and the test-case passes with and
without the patch.  Still, there's no apparent reason why
LRA prefers "move R1,R2" "and I,R2" to "move I,R1" "and
R1,R2", or why that wouldn't "randomly" change (also seen
with other operations than "and").  Thus committed.

gcc:
* config/cris/cris.md (movandsplit1): New define_peephole2.

gcc/testsuite:
* gcc.target/cris/peep2-movandsplit1.c: New test.
gcc/config/cris/cris.md
gcc/testsuite/gcc.target/cris/peep2-movandsplit1.c [new file with mode: 0644]