Landing: ce6a2e934906

Project / Subsystem

gcc / match.pd

Date

2026-08-13

Author

Dominic P

Commit

ce6a2e9349065db52a7e25808aefc97ddaef9cba

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match.pd
patch_id
—
commit_hash
ce6a2e9349065db52a7e25808aefc97ddaef9cba
source_type
github
headline
match.pd: Fold (t * u) % u to zero when multiplication cannot overflow
tldr
Optimization rule added to simplify expressions like (t * u) % u to zero if the multiplication is guaranteed not to overflow.
author
Dominic P
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • arithmetic
discussion_id_link
—
bugzilla_pr
—
date
2026-08-13T00:00:00.000Z

A new simplification rule has been added to match.pd to handle expressions of the form (t * u) % u. When the multiplication t * u is guaranteed to not overflow, the result of the modulo operation will always be zero. This rule applies to various modulo codes (TRUNC_MOD_EXPR, MODULO, mod) and extends the existing fold for (t * u) / u to its remainder counterpart, improving code efficiency by eliminating redundant operations.