Landing: 57797c6404d8
Project / Subsystem
gcc / gcc
Date
2026-05-03
Author
Jeff Law
Commit
57797c6404d81fdfa798c21b88ae6d8e19b23fd8
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc
- patch_id
- —
- commit_hash
- 57797c6404d81fdfa798c21b88ae6d8e19b23fd8
- source_type
- github
- headline
- RISC-V: Improve Code Generation for Select Between 2^n and 0
- tldr
- GCC now generates more efficient RISC-V code for selecting between a power of 2 and zero, potentially saving bytes and improving performance.
- author
- Jeff Law
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • risc-v
- • code generation
- • optimization
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-03T00:00:00.000Z
GCC now generates more efficient RISC-V code for conditional expressions that select between a power of 2 (2^n) and 0. This optimization replaces a sequence of instructions with a shift-and-subtract, reducing code size and potentially improving performance by increasing the number of operations per fetch block. The change lays the groundwork for further generalizations to handle selecting between other constants.