Landing: 58bf8a355a73

Project / Subsystem

gcc / tree-optimization

Date

2026-08-23

Author

Dominic P

Commit

58bf8a355a73b7fbc6d7bfebcc7281b3cdadd4da

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
tree-optimization
patch_id
—
commit_hash
58bf8a355a73b7fbc6d7bfebcc7281b3cdadd4da
source_type
github
headline
Hoist shifts by in-range constants out of loops
tldr
Improves loop optimization by hoisting shifts with constant counts that are provably in range.
author
Dominic P
outcome
committed
performance_win
true
breaking_change
false
series_id
gcc:tree-optimization: hoist shifts by an in-range constant count
series_parts
[]
tags
  • • optimization
  • • loop optimization
  • • shifts
  • • ARM
discussion_id_link
—
bugzilla_pr
—
date
2026-08-23T00:00:00.000Z

This commit corrects a bug in loop optimization where shifts with constant counts were incorrectly restricted from being hoisted out of loops. The movement_possibility_1 logic mistakenly pinned shifts with in-range counts, while shifts with out-of-range counts were incorrectly marked as movable. The fix inverts this logic, allowing shifts with constant counts that are proven to be in range to be hoisted. This can lead to performance improvements by reducing redundant computations within loop bodies, as demonstrated by reductions in loop-invariant code and register pressure on ARM targets.