The first three patches use instructions shared with Zbb for logical
constants, halfword zero extension and a rotate-and-invert idiom.

Patch 4 uses Zbkc for reversed CRC64 updates on RV64 with 32- or
64-bit inputs.  In a 4 KiB microbenchmark compiled for rv64gc_zbkc,
inlining these updates reduced cycles by 59% and 83% on a SpacemiT K1,
58% and 81% on gem5 Minor, and 69% and 88% on four-wide gem5 O3.
Both gem5 models used their integer multiply units for clmul and clmulh.

The Zbkx patch uses xperm8 for byte swaps when optimizing for speed.
In LZ4's xxHash implementation this removes the libgcc call in all
four canonical-format conversion functions on both RV32 and RV64.

Tested with toolchain make report-gcc on RV32GC/ILP32D and RV64GC/LP64D.
GCC C selftests and RV32/RV64 QEMU checks against a bitwise CRC reference
also passed.

Jiawei (5):
  RISC-V: Use inverted logical instructions for constants with Zbkb
  RISC-V: Use zext.h for unsigned halfword extension with Zbkb
  RISC-V: Use rori and xori for a complemented sign bit with Zbkb
  RISC-V: Use Zbkc for wide CRC64 updates on RV64
  RISC-V: Expand byte swaps with xperm8 on Zbkx targets

 gcc/config/riscv/bitmanip.md                  | 49 ++++++++++++-------
 gcc/config/riscv/riscv.cc                     | 37 +++++++++-----
 gcc/config/riscv/riscv.md                     | 10 ++--
 gcc/testsuite/gcc.target/riscv/crc-rev-zbkc.c | 20 ++++++++
 gcc/testsuite/gcc.target/riscv/pr121778-3.c   | 12 +++++
 .../gcc.target/riscv/zbkb-logic-imm.c         | 11 +++++
 gcc/testsuite/gcc.target/riscv/zbkb-zext-h.c  | 11 +++++
 gcc/testsuite/gcc.target/riscv/zbkx-bswap.c   | 19 +++++++
 8 files changed, 132 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/crc-rev-zbkc.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/pr121778-3.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/zbkb-logic-imm.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/zbkb-zext-h.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/zbkx-bswap.c


base-commit: 6041d224ab85e557ba219de04e7b5637aeb994b3

Reply via email to