Landing: 373e2c30b171
Project / Subsystem
gcc / gcc/arm
Date
2026-06-05
Author
Roger Sayle
Commit
373e2c30b1710e271664cf95fcfb66fea7dd15ed
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/arm
- patch_id
- —
- commit_hash
- 373e2c30b1710e271664cf95fcfb66fea7dd15ed
- source_type
- github
- headline
- Improved RTX costs from -mthumb on ARM.
- tldr
- Fixes wildly inaccurate instruction costs for Thumb-1, cutting generated code from 11 to 5 instructions in some shifts.
- author
- Roger Sayle
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • arm
- • thumb-1
- • rtx-costs
- • code-generation
- • optimization
- discussion_id_link
- github:gcc-mirror/gcc#122871
- bugzilla_pr
- —
- date
- 2026-06-05T00:00:00.000Z
The ARM backend’s thumb1_rtx_costs function returned unrealistic costs for basic operations like addition, shifts, and bitwise ops, causing the optimiser to select terrible instruction sequences. This patch overhauls costs for PLUS, MINUS, shifts, and logical ops across SI/DI/HI/QImode, bringing them into line with what the Thumb-1 ISA actually supports. A 64-bit shift-add sequence that previously compiled to 11 instructions now emits 5, because the optimiser can finally see that a left-shift-by-one is cheaper than repeatedly adding and subtracting. The fix also addresses a host compiler warning in comp_not_to_clear_mask_str_un.