[committed] Provide patterns for signed bitfield extractions on H8
commit73f6e1fe8835085ccc6de5c5f4428d47e853913b
authorJeff Law <jlaw@ventanamicro.com>
Sun, 10 Dec 2023 17:29:23 +0000 (10 10:29 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Sun, 10 Dec 2023 17:29:23 +0000 (10 10:29 -0700)
treeb16753597fe272f8933cfcdc7e06a83a3ff0cd8a
parent1f55c5cc698519094f751257db62ff274c015fdc
[committed] Provide patterns for signed bitfield extractions on H8

Inspired by Roger's work on the ARC port, this patch provides a
define_and_split pattern to optimize sign extended bitfields starting at
position 0 using an approach that doesn't require shifting.

It then builds on that to provide another define_and_split pattern to support
arbitrary signed bitfield extractions -- it uses a right logical shift to move
the bitfield into position 0, then the specialized pattern above to sign extend
the MSB of the field through the rest of the register.

This is often, but certainly not always, better than a two shift approach.  The
code uses the sizes of the sequences to select between the two shift approach
and single shift with extension from an arbitrary location approach.

There's certainly further improvements that could be made here, but I think
we're getting the bulk of the improvements already.

Regression tested on the H8 port without errors.  Installing on the trunk.

gcc/
* config/h8300/h8300-protos.h (use_extvsi): Prototype.
* config/h8300/combiner.md: Two new define_insn_and_split patterns
to implement signed bitfield extractions.
* config/h8300/h8300.cc (use_extvsi): New function.
gcc/config/h8300/combiner.md
gcc/config/h8300/h8300-protos.h
gcc/config/h8300/h8300.cc