[to-be-committed] [RISC-V] Some basic patterns for zbkb code generation
And here's Lyut's basic Zbkb support. Essentially it's four new patterns for
packh, packw, pack plus a bridge pattern needed for packh.
packw is a bit ugly as we need to match a sign extension in an inconvenient
location. We pull it out so that the extension is exposed in a convenient
place for subsequent sign extension elimination.
We need a bridge pattern to get packh. Thankfully the bridge pattern is a
degenerate packh where one operand is x0, so it works as-is without splitting
and provides the bridge to the more general form of packh.
This patch also refines the condition for the constant reassociation patch to
avoid a few more cases than can be handled efficiently with other preexisting
patterns and one bugfix to avoid losing bits, particularly in the xor/ior case.
Lyut did the core work here. I think I did some minor cleanups and the bridge
pattern to work with gcc-15 and beyond.
This is a prerequisite for using zbkb in constant synthesis. It also stands on
its own. I know we've seen it trigger in spec without the constant synthesis
bits.
It's been through our internal CI and my tester. I'll obviously wait for the
upstream CI to finish before taking further action.
gcc/
* config/riscv/crypto.md: Add new combiner patterns to generate
pack, packh, packw instrutions.
* config/riscv/iterators.md (HX): New iterator for half X mode.
* config/riscv/riscv.md (<optab>_shift_reverse<X:mode>): Tighten
cases to avoid. Do not lose bits for XOR/IOR.
gcc/testsuite
* gcc.target/riscv/pack32.c: New test.
* gcc.target/riscv/pack64.c: New test.
* gcc.target/riscv/packh32.c: New test.
* gcc.target/riscv/packh64.c: New test.
* gcc.target/riscv/packw.c: New test.
Co-authored-by: Jeffrey A Law <jlaw@ventanamicro.com>