]> git.ipfire.org Git - thirdparty/gcc.git/commit
[to-be-committed] [RISC-V] Some basic patterns for zbkb code generation
authorLyut Nersisyan <lyut.nersisyan@gmail.com>
Tue, 28 May 2024 15:17:50 +0000 (09:17 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Tue, 28 May 2024 15:22:28 +0000 (09:22 -0600)
commit236116068151bbc72aaaf53d0f223fe06f7e3bac
tree19b32ff6bb9f14fac7cb7b5645d5b16f1a85b670
parenta3aeff4ce95bd616a2108dc2363d9cbaba53b170
[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>
gcc/config/riscv/crypto.md
gcc/config/riscv/iterators.md
gcc/config/riscv/riscv.md
gcc/testsuite/gcc.target/riscv/pack32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/pack64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/packh32.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/packh64.c [new file with mode: 0644]
gcc/testsuite/gcc.target/riscv/packw.c [new file with mode: 0644]