RISC-V: Preserve masks when complementing shift counts
RISC-V shift instructions preserve masks during complement operations.
This change ensures that the masks associated with shift counts are preserved when rewriting a shift count as a complement on RISC-V architectures. Previously, dropping these masks could lead to incorrect code generation when later optimizations selected XLEN-wide instructions. The fix applies to both native and word splitters, maintaining existing masked shift patterns and adding runtime tests to verify correctness.
In Details
In RISC-V code generation, shift operations often involve masks derived from the shift count. When a shift count is complemented (e.g., 31 - x), the original mask associated with x could be dropped. This commit corrects the splitters in riscv.md to retain these masks, preventing incorrect instruction selection by later passes like combine, especially when Zbs instructions are involved. The change ensures correctness for both word-split and native shift-count representations.