Landing: ae033e5cef61

Project / Subsystem

gcc / match

Date

2026-09-08

Author

Dominic P

Commit

ae033e5cef61cf9dd2a7489fbd2037d57f9483a7

Source

github

Perf win

Yes

Breaking

No

All attributes

project
gcc
subsystem
match
patch_id
—
commit_hash
ae033e5cef61cf9dd2a7489fbd2037d57f9483a7
source_type
github
headline
match.pd: Fold rounded-up average idiom, dual to floor rule
tldr
New pattern in match.pd recognizes and simplifies a common rounded-up average calculation, improving code generation for media codecs.
author
Dominic P
outcome
committed
performance_win
true
breaking_change
false
series_id
—
series_parts
[]
tags
  • • optimization
  • • pattern matching
discussion_id_link
—
bugzilla_pr
—
date
2026-09-08T00:00:00.000Z

A new pattern has been added to match.pd to recognize and fold a specific idiom for calculating a rounded-up average: ((x >> 1) + (y >> 1)) + ((x | y) & 1). This idiom is mathematically equivalent to (x | y) - ((x ^ y) >> 1), which is a more optimized form. This change is particularly relevant for targets with averaging instructions and for vector types, where it reduces the number of instructions generated for motion-compensation averages in media codecs.