RISC-V: Adjust splitter to avoid incorrect rewrite with Zbkb
Fixes a RISC-V optimization that incorrectly rewrote arithmetic operations under specific conditions.
This commit refines a RISC-V optimization splitter that rewrites expressions of the form (x << C1) + C2 into (x + C2') << C1. The change prevents this rewrite from occurring when the Zbkb extension is enabled and the shift count (C1) is half the word size, a scenario that is better handled by specialized instructions within Zbkb.
In Details
Adjusts the condition for a RISC-V optimization splitter in riscv.md that targets (x << C1) + C2 patterns. The splitter now avoids firing when Zbkb is enabled and C1 is equal to half the word size, as this specific case is better handled by the Zbkb packing instructions. This prevents an incorrect rewrite that could otherwise occur.
- AOP
- Arithmetic Optimization Passes. A set of compiler passes in GCC that aim to optimize arithmetic operations for improved performance, often by using specialized instructions or algebraic transformations.
- RISC-V
- An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computing principles. GCC supports various RISC-V profiles and extensions.
- Zbkb
- A RISC-V base integer instruction set extension that includes bit manipulation instructions, particularly for packing and unpacking data. It provides efficient ways to combine or split data at the bit level.
- splitter
- In compiler optimization, a 'splitter' is a pattern-matching mechanism that identifies specific code structures which can be beneficially transformed or replaced with a more efficient equivalent.