CRIS: peephole2 an "and" with a contiguous "one-sided" sequences of 1s
commit8c361179c01dccb2abfff1ab447adcbea4429437
authorHans-Peter Nilsson <hp@axis.com>
Mon, 17 Apr 2023 02:54:03 +0000 (17 04:54 +0200)
committerHans-Peter Nilsson <hp@bitrange.com>
Thu, 4 May 2023 00:46:53 +0000 (4 02:46 +0200)
tree869884cf09bf7faff22125ee87c5b0285a010fbd
parente88d9e826ee68219dd4dbb2c0d8bdaee0a864301
CRIS: peephole2 an "and" with a contiguous "one-sided" sequences of 1s

This kind of transformation seems pretty generic and might be a
candidate for adding to the middle-end, perhaps as part of combine.

I noticed these happened more often for LRA, which is the reason I
went on this track of low-hanging-fruit-microoptimizations that are
such an itch when noticing them, inspecting generated code for libgcc.
Unfortunately, this one improves coremark only by a few cycles at the
beginning or end (<0.0005%) for cris-elf -march=v10.  The size of the
coremark code is down by 0.4% (0.22% pre-lra).

Using an iterator from the start because other binary operations will
be added and their define_peephole2's would look exactly the same for
the .md part.

Some existing and-peephole2-related tests suffered, because many of
them were using patterns with only contiguous 1:s in them: adjusted.
Also, spotted and fixed, by adding a space, some
scan-assembler-strings that were prone to spurious identifier or file
name matches.

gcc:
* config/cris/cris.cc (cris_split_constant): New function.
* config/cris/cris.md (splitop): New iterator.
(opsplit1): New define_peephole2.
* config/cris/cris-protos.h (cris_split_constant): Declare.
(cris_splittable_constant_p): New macro.

gcc/testsuite:
* gcc.target/cris/peep2-andsplit1.c: New test.
* gcc.target/cris/peep2-andu1.c, gcc.target/cris/peep2-andu2.c,
gcc.target/cris/peep2-xsrand.c, gcc.target/cris/peep2-xsrand2.c:
Adjust values to avoid interference with "opsplit1" with AND.  Add
whitespace to match-strings that may be confused with identifiers
or file names.
gcc/config/cris/cris-protos.h
gcc/config/cris/cris.cc
gcc/config/cris/cris.md
gcc/testsuite/gcc.target/cris/peep2-andsplit1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/cris/peep2-andu1.c
gcc/testsuite/gcc.target/cris/peep2-andu2.c
gcc/testsuite/gcc.target/cris/peep2-xsrand.c
gcc/testsuite/gcc.target/cris/peep2-xsrand2.c