Fix long branch sequences for Andes RISC-V extensions
Corrects conditional branch logic for Andes RISC-V extensions, resolving long branch issues.
This commit addresses issues with long branch sequences for Andes RISC-V extensions, which introduce new conditional branch instructions. The problem lay in inverting the condition for long branches: when a short direct branch wouldn’t fit, the compiler needed to branch around a long unconditional branch. The inversion logic for the condition was missing, causing incorrect branching behavior. The fix ensures the correct condition is used for long branches in these Andes extensions.
In Details
This commit corrects the handling of long conditional branches for Andes extensions on RISC-V. The Andes ISA includes new conditional branch instructions (e.g., branch-on-bit, equality with small constants). The issue was in config/riscv/andes.md, where the condition for a long branch (branching around an unconditional jump) was not inverted correctly. The fix involves introducing new iterators sc (inverted from cs) and any_eq_inv (swapping eq/ne mappings) in config/riscv/iterators.md and applying the correct inverted condition in the andes.md patterns. The fix was verified by ins…
- RISC-V
- An open-standard instruction set architecture based on RISC principles. It is designed to be simple, modular, and extensible.
- Andes extensions
- Specific instruction set extensions developed by Andes Technology Corporation for the RISC-V architecture, often targeting embedded systems.
- long branch
- A branch instruction that requires more space than a standard short branch to encode its target address. Compilers must generate sequences that accommodate these longer instruction formats.
- conditional branch
- An instruction that transfers program control to a different location based on whether a specified condition is met (e.g., if a value is zero or non-zero).
- machine description (MD) file
- Files used by GCC to describe the instruction set, addressing modes, and other architectural details of a target processor. This information is used by the backend to generate machine code.