Landing: 3791d1b507c5

Project / Subsystem

gcc / match

Date

2026-07-29

Author

Kyrylo Tkachov

Commit

3791d1b507c5715bc350d740dec70f4b06f19a96

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match
patch_id
—
commit_hash
3791d1b507c5715bc350d740dec70f4b06f19a96
source_type
github
headline
match: Fold sum of MIN/MAX pair into a single expression.
tldr
Optimizes expressions like (a + b) - MIN(a, b) to simplify to MAX(a, b).
author
Kyrylo Tkachov
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • algebraic simplification
discussion_id_link
—
bugzilla_pr
—
date
2026-07-29T00:00:00.000Z

This commit introduces a new simplification rule in match.pd that folds expressions of the form (x + y) - MIN(x, y) into MAX(x, y). This algebraic identity holds for both integers and floating-point numbers (under certain conditions like reassociation). The optimization simplifies code by reducing the number of operations required, as demonstrated by an example reducing four instructions to one on AArch64.