Landing: ee69b433860e
Project / Subsystem
gcc / ifcvt
Date
2026-07-16
Author
Kyrylo Tkachov
Commit
ee69b433860e8017974df2bb499924a5fd1c7894
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- ifcvt
- patch_id
- —
- commit_hash
- ee69b433860e8017974df2bb499924a5fd1c7894
- source_type
- github
- headline
- ifcvt: Make average_cost independent of arm order [PR125557]
- tldr
- The `ifcvt` optimization's average cost calculation is fixed to be independent of control flow arm order, preventing incorrect conditional move decisions.
- author
- Kyrylo Tkachov
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • ifcvt
- • bugfix
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-16T00:00:00.000Z
This commit addresses a bug in the ifcvt (if-conversion) optimization where the average_cost calculation was sensitive to the order of control flow arms. The previous implementation could lead to different decisions about converting if statements to conditional moves based on whether the ‘then’ or ‘else’ branch appeared first. The fix ensures the calculation is commutative by always starting with the cheaper arm and scaling the difference by the probability of the more expensive arm, improving the robustness and correctness of the optimization.