Following Jeff's suggestion[1], this series handles two masked-count forms:
* Zbs: combine inverted bit extraction into bext and seqz, eliminating the separate count mask while retaining valid split RTL. * Zbb/Zbkb: reverse the rotation direction for negative counts, removing neg/negw for native and RV64 word rotations. Masks that affect the effective count are preserved. [1] https://gcc.gnu.org/pipermail/gcc-patches/2026-October/736421.html Based on trunk commit a89bad222e954a9c1a4f29112c75174ad4e54213. Testing ------- Tested riscv64-unknown-elf with rv32gc/ilp32d and rv64gc/lp64d multilib boards under QEMU 11.0.2, using: make report-gcc -j16 RUNTESTFLAGS="riscv.exp" No regressions relative to the unmodified baseline. The new assembly tests pass; the existing 233 FAIL and 117 UNRESOLVED results are unchanged. Additional QEMU correctness checks passed in all 48 configurations (24 per compiler), covering RV32/RV64, -O2/-Os and six extension combinations. Performance ----------- Three focused RV64 microkernels compiled at -O2 each save one instruction per iteration. The kernel machine code is unchanged after rebasing. Values are reductions (%) relative to the baseline: Instructions Cycles RV64 kernel gem5 K1 Minor O3 K1 Inverted extraction 11.11 11.11 9.99 14.27 14.29 Native negative rotate 16.66 16.67 0.00 24.97 24.95 Word negative rotate 14.28 14.28 33.21 24.95 19.93 gem5 used generic Minor/O3 models. K1 results are medians of 15 paired reductions measured with PMU instructions/cycles on a pinned core. These are microkernel results, not whole-application speedups. 1. RISC-V: Fold masked counts in inverted bit extraction 2. RISC-V: Reverse rotations with masked negative counts
