Landing: 980c3302d34f
Project / Subsystem
gcc / gcc/match
Date
2026-07-29
Author
Kyrylo Tkachov
Commit
980c3302d34f1a6977f69cacbe327ac894844e1d
Source
github
Perf win
Yes
Breaking
No
All attributes
- project
- gcc
- subsystem
- gcc/match
- patch_id
- —
- commit_hash
- 980c3302d34f1a6977f69cacbe327ac894844e1d
- source_type
- github
- headline
- Fold remainder of a remainder by a multiple
- tldr
- GCC simplifies nested modulo operations where the inner modulus divides the outer one, reducing redundant calculations.
- author
- Kyrylo Tkachov
- outcome
- committed
- performance_win
- true
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • optimization
- • integer
- • arithmetic
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-07-29T00:00:00.000Z
GCC can now simplify expressions of the form (x % C1) % C2 when C2 is a divisor of C1. This optimization, implemented in the match.pd system, replaces the nested remainder operations with a single remainder operation x % C2, effectively removing one division from the generated code. This is beneficial for performance, as division operations are typically more expensive than modulo operations.