Landing: 23797f88d163

Project / Subsystem

gcc / gcc/match.pd

Date

2026-08-10

Author

Kyrylo Tkachov

Commit

23797f88d1635d38ce68c8d180a0f90a1ea34740

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
gcc/match.pd
patch_id
—
commit_hash
23797f88d1635d38ce68c8d180a0f90a1ea34740
source_type
github
headline
Fold inequality spelling of divisibility
tldr
Extends divisibility optimization to handle inequality conditions.
author
Kyrylo Tkachov
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • pattern-matching
  • • aarch64
discussion_id_link
—
bugzilla_pr
—
date
2026-08-10T00:00:00.000Z

GCC now optimizes divisibility checks involving inequalities, similar to how it handles equalities. Previously, an expression like x / y * y == x could be simplified to x % y == 0. This change extends that optimization to also cover x / y * y != x, which simplifies to x % y != 0. This optimization can lead to more efficient code generation, as demonstrated by an example on AArch64.