RISC-V: Reject non-monotonic shuffle masks in slide patterns
RISC-V vector shuffle slide patterns now correctly reject non-monotonic masks, fixing wrong code generation.
RISC-V vector shuffle slide patterns incorrectly accepted non-monotonic masks, leading to incorrect code generation at -O0. This change verifies that the sequence endpoints match expected positions for OP0 and OP1, rejecting invalid patterns. A new test case has been added to cover this fix.
In Details
The shuffle_slide_patterns function in RISC-V vector processing incorrectly validated combined slideup/slidedown sequences. It failed to ensure the permute mask endpoints aligned with the expected OP0 and OP1 positions, allowing non-monotonic masks. This commit adds checks for d->perm[0] and d->perm[vlen - 1] against calculated boundary positions, and also rejects a second pivot when need_slideup_p is set, ensuring correct code generation.
- RISC-V V extension
- A set of instructions for RISC-V that supports vector processing, enabling SIMD (Single Instruction, Multiple Data) operations for improved performance on parallelizable tasks.
- Shuffle (vector)
- A vector operation that rearranges elements within one or more vectors according to a specified permutation mask. This allows for complex data reordering needed in various algorithms.
- Slide pattern (vector)
- A specific type of vector shuffle operation that effectively shifts elements within a vector, often used for operations like strided access or implementing sliding windows.
- Non-monotonic mask
- In the context of vector shuffle masks, a mask where the element indices do not strictly increase or decrease, which can lead to unexpected data arrangements if not handled correctly.