RISC-V: Adds missing splitters for zicond sequences to improve x264 performance
Adds two missing instruction pattern splitters for RISC-V's zicond extension, improving performance on x264 by an estimated 10 million instructions.
This commit introduces two missing instruction pattern splitters for the RISC-V zicond extension, specifically for combined (LT/LTU & EQ/NE) and (LE/LEU & EQ/NE) conditions. An LLVM review of x264 code on RISC-V revealed these omissions, where the operands for logical AND operations could be in either order, but not all splitters supported reversed operands. Adding these splitters resolves the oversight and is expected to yield a significant reduction in instruction count for x264, while maintaining compatibility.
In Details
This commit modifies gcc/config/riscv/zicond.md to add missing reciprocal operand orderings for zicond splitters. The zicond extension in RISC-V provides conditional load/store and branch instructions. The issue arises when combining conditions, e.g., (LT & EQ), where the backend needs to recognize patterns regardless of operand order. This patch adds the necessary recognizer forms for (LT/LTU & EQ_NE) and (LE/LEU & EQ/NE) to handle these combinations correctly, improving code generation efficiency for certain instruction sequences.
- zicond
- A RISC-V 'custom extension' that provides new conditional instructions, useful for optimizing sequences involving both comparison and logical operations.
- splitter
- In compiler backend code generation, a splitter is a pattern that breaks down a complex instruction into simpler ones that the target architecture can directly execute. It's part of instruction recognition and selection.
- RISC-V
- An open-standard Instruction Set Architecture (ISA) based on Reduced Instruction Set Computing principles, designed for simplicity and modularity.
- x264
- A popular free and open-source software library for encoding video streams into the H.264/MPEG-4 AVC format.