RISC-V avoids vsetvl insertion on shared jump table edges
RISC-V compiler avoids inserting vsetvl configurations on edges shared by jump tables, preventing ICEs.
This change prevents the RISC-V compiler from inserting vsetvl configurations on edges that are part of shared jump tables. Previously, such insertions could occur on edges from shared jump-table dispatches, leading to an ICE when the jump table was split for one dispatch but used by others. The fix ensures local configurations are maintained in blocks with incoming shared-table edges, resolving an ICE and allowing a new test case to pass.
In Details
This commit modifies the RISC-V backend's handling of late vsetvl PRE (pre-register-extension) optimization. Specifically, it prevents vsetvl configuration instructions from being inserted on control flow graph (CFG) edges originating from jump tables that are shared across multiple dispatch sites. The invalid_opt_bb_p check is used to identify and preserve local configurations in blocks with incoming shared-table edges, thus avoiding conflicts and potential ICEs like rtl_split_edge that arise when shared edges are modified for a single dispatch.
- vsetvl
- A RISC-V vector instruction that sets the vector length (VL) and vector type (VTYPE) for subsequent vector operations. Its configuration is crucial for vector processing.
- PRE
- Partial Redundancy Elimination. A compiler optimization that eliminates redundant computations by identifying and removing duplicate expressions.
- ICE
- Internal Compiler Error. A fatal error that occurs within the compiler itself, usually due to a bug in the compiler's logic or optimization passes.
- CFG
- Control Flow Graph. A graphical representation of the execution paths within a program, where nodes represent basic blocks and edges represent control flow transfers.
- jump table
- A data structure used to implement efficient multi-way branching. It typically contains addresses of target code blocks, allowing a program to jump to a specific block based on an index.