Landing: c585baad310a

Project / Subsystem

gcc / expmed

Date

2026-07-12

Author

Jeff Law

Commit

c585baad310a4a5394ff90222faa6933d261fc90

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
expmed
patch_id
commit_hash
c585baad310a4a5394ff90222faa6933d261fc90
source_type
github
headline
Optimize 32-bit unsigned division by constants on 64-bit targets.
tldr
New expansion strategy for constant division on 64-bit targets reduces instruction count.
author
Jeff Law
outcome
committed
performance_win
true
breaking_change
false
series_id
series_parts
[]
tags
  • optimization
  • x86_64
  • division
discussion_id_link
bugzilla_pr
date
2026-07-12T00:00:00.000Z

GCC now employs a new strategy for 32-bit unsigned integer division by constants on 64-bit targets when the division requires a wide magic multiplier. This method uses a pre-shifted magic constant in a doubled-width mode, enabling a single high-part multiply operation. The compiler selects this approach only when its instruction count is comparable to or better than the traditional sub/shift/add sequence, reducing instructions from 7 to 4 for divisions like x/7 on x86_64.