Landing: 9f6eb7d29930

Project / Subsystem

gcc / gcc

Date

2026-09-17

Author

Richard Biener

Commit

9f6eb7d2993046e5720275f590098db0ac0188d4

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
gcc
patch_id
—
commit_hash
9f6eb7d2993046e5720275f590098db0ac0188d4
source_type
github
headline
Fix loop unroller epilogue bound when control IV wraps.
tldr
Corrects loop unroller's epilogue iteration count when the loop control variable wraps around.
author
Richard Biener
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • loop unrolling
discussion_id_link
—
bugzilla_pr
—
date
2026-09-17T00:00:00.000Z

This commit fixes a bug in GCC’s loop unrolling optimization where the epilogue loop’s iteration bound was incorrectly calculated when the loop’s control variable wraps. Previously, the unroller assumed the main loop consumed all but fewer than FACTOR iterations. However, when the control IV wraps, this assumption breaks, leading to miscompilation. The fix ensures the epilogue bound is only set when the exit test is not a NE_EXPR or when the control IV is known not to wrap, otherwise inheriting the original loop’s bound.