CRIS: peephole2 a lsrq into a lslq+lsrq pair
commit0a5e8d492a7efc739110289bf97ef4c9fe0674f4
authorHans-Peter Nilsson <hp@axis.com>
Thu, 20 Apr 2023 05:14:26 +0000 (20 07:14 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Fri, 5 May 2023 23:15:30 +0000 (6 01:15 +0200)
treeaac4d5968888f59b74b17ffdf8de972bc6c57543
parent07527e3eabb00ada0e7c9e083084e4e56d97f34f
CRIS: peephole2 a lsrq into a lslq+lsrq pair

Observed after opsplit1 with AND in libgcc floating-point
functions, like the first spottings of opsplit1/AND
opportunities.  Two patterns are nominally needed, as the
peephole2 optimizer continues from the *first replacement*
insn, not from a minimum context for general matching; one
that includes it as the last match.

But, the "free-standing" opportunity (three shifts) didn't
match by itself in a gcc build of libraries plus running the
test-suite, and thus deemed uninteresting and left out.
(As expected; if it had matched, that'd have indicated a
previously missed optimization or other problem elsewhere.)
Only the one that includes the previous define_peephole2
that may generate the sequence (i.e. opsplit1/AND), matches
easily.

Coremark results aren't impressive though: 0.003%
improvement in speed and slightly less than 0.1% in size.

A testcase is added to match and another one to cover a case
of movulsr checking that it's used; it's preferable to
lsrandsplit when both would match.

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

gcc/testsuite:
* gcc.target/cris/peep2-lsrandsplit1.c,
gcc.target/cris/peep2-movulsr2.c: New tests.
gcc/config/cris/cris.md
gcc/testsuite/gcc.target/cris/peep2-lsrandsplit1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/cris/peep2-movulsr2.c [new file with mode: 0644]