Landing: c29a38d644bb
Project / Subsystem
gcc / riscv
Date
2026-05-01
Author
Philipp Tomsich
Commit
c29a38d644bb6984875d92acac9b30a133dacd6f
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- riscv
- patch_id
- —
- commit_hash
- c29a38d644bb6984875d92acac9b30a133dacd6f
- source_type
- github
- headline
- RISC-V: Optimize power-of-2 boundary comparisons in conditional moves.
- tldr
- Optimizes conditional moves by converting power-of-2 boundary comparisons into shift-based equality tests.
- author
- Philipp Tomsich
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • riscv
- • optimization
- • conditional move
- • code generation
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-05-01T00:00:00.000Z
The RISC-V backend optimizes conditional moves by detecting unsigned comparisons against power-of-2 boundaries and converting them to shift-based equality tests. This avoids materializing large constants, replacing them with a single shift instruction. This optimization improves code generation for expressions like (a & (0xff << 56)) ? b : 0.