Landing: 471022256e47
Project / Subsystem
gcc / tree-optimization
Date
2026-09-21
Author
Richard Biener
Commit
471022256e4705314aedf21c53bc351ece88ff43
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- tree-optimization
- patch_id
- —
- commit_hash
- 471022256e4705314aedf21c53bc351ece88ff43
- source_type
- github
- headline
- ivopts: Fix loop bound calculation when counter wraps
- tldr
- Corrects loop invariant code motion to handle counter wrap-around during increment.
- author
- Richard Biener
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • tree-optimization
- • loop-optimization
- • bugfix
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-09-21T00:00:00.000Z
This commit fixes a bug in the loop invariant code motion pass (ivopts) that miscalculated loop bounds when the loop counter wraps around during its first increment. Previously, the calculation assumed non-wrapping behavior, leading to incorrect iteration counts and potentially premature loop termination. The fix adjusts the bound calculation to consider a + 1 and b + 1 instead of a and b, ensuring correct behavior even when the counter reaches its maximum value and wraps to zero.