Landing: e8f4e91989f0

Project / Subsystem

gcc / match

Date

2026-08-10

Author

Kael Andrew Alonzo Franco

Commit

e8f4e91989f0b57463f1b726f94344ddbe2bb128

Source

github

Perf win

No

Breaking

No

All attributes

project
gcc
subsystem
match
patch_id
—
commit_hash
e8f4e91989f0b57463f1b726f94344ddbe2bb128
source_type
github
headline
match: 1 / X -> X == 1 for positive X. [PR125735]
tldr
Correctly optimizes division by a variable in GCC's pattern matching to improve code generation.
author
Kael Andrew Alonzo Franco
outcome
committed
performance_win
false
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • bugfix
discussion_id_link
—
bugzilla_pr
—
date
2026-08-10T00:00:00.000Z

This commit corrects a pattern matching rule in GCC’s tree-optimization passes. Previously, the rule for 1 / X when X was positive was not correctly identified as equivalent to X == 1. This change uses tree_expr_nonnegative_p to ensure signed positive values are handled, leading to more accurate optimization of division operations.