V3 fixes a pre-existing bug that drops masks when complementing shift counts. Patch 1 preserves the masks so later Zbs combinations cannot use an extra count bit, and adds a runtime test. Patch 2 retains the v2 word-mask patterns, including bclr with Zbs alone.
Full GCC C/C++ testing with separate baseline and patched compilers found no new regressions against ef1af9e6a6cc. Testing used toolchain make report-gcc -j12 without a testsuite filter on RV32/ILP32D and RV64/LP64D with Zba, Zbb and Zbs enabled. C selftests and RV32/RV64 QEMU checks also passed. At -O2 with RV64 Zbb+Zbs, the scalar-call microbenchmarks retire 7.68% fewer instructions in gem5 and about 7.69% fewer on K1. Minor cycles are unchanged, O3 cycles decrease by 0.04%, and K1 cycles decrease by 27.05-27.14%. These figures include call overhead and reuse earlier measurements: rebuilt gem5 ELFs and K1 kernel code match the measured versions. Jiawei (2): RISC-V: Preserve masks when complementing shift counts RISC-V: Combine zero-extended word masks with Zbs operations gcc/config/riscv/bitmanip.md | 43 +++++++++++++++ gcc/config/riscv/riscv.md | 19 ++++--- gcc/testsuite/gcc.target/riscv/pr123838.c | 1 + .../riscv/shift-count-complement-1.c | 54 +++++++++++++++++++ .../gcc.target/riscv/zbs-word-mask-2.c | 13 +++++ .../gcc.target/riscv/zbs-word-mask.c | 25 +++++++++ 6 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/shift-count-complement-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbs-word-mask-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/zbs-word-mask.c base-commit: 0b13c6015560dfbcedc8d130623ba126927fba22
